* [PATCH] erofs: using switch-case while checking the inode type.
@ 2019-08-30 9:56 Pratik Shinde
2019-08-30 11:59 ` Gao Xiang via Linux-erofs
0 siblings, 1 reply; 6+ messages in thread
From: Pratik Shinde @ 2019-08-30 9:56 UTC (permalink / raw)
To: linux-erofs, gaoxiang25, yuchao0; +Cc: devel, gregkh
while filling the linux inode, using switch-case statement to check
the type of inode.
switch-case statement looks more clean here.
Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
---
fs/erofs/inode.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 80f4fe9..6336cc1 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -190,22 +190,28 @@ static int fill_inode(struct inode *inode, int isdir)
err = read_inode(inode, data + ofs);
if (!err) {
/* setup the new inode */
- if (S_ISREG(inode->i_mode)) {
+ switch (inode->i_mode & S_IFMT) {
+ case S_IFREG:
inode->i_op = &erofs_generic_iops;
inode->i_fop = &generic_ro_fops;
- } else if (S_ISDIR(inode->i_mode)) {
+ break;
+ case S_IFDIR:
inode->i_op = &erofs_dir_iops;
inode->i_fop = &erofs_dir_fops;
- } else if (S_ISLNK(inode->i_mode)) {
+ break;
+ case S_IFLNK:
/* by default, page_get_link is used for symlink */
inode->i_op = &erofs_symlink_iops;
inode_nohighmem(inode);
- } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
- S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
+ break;
+ case S_IFCHR:
+ case S_IFBLK:
+ case S_IFIFO:
+ case S_IFSOCK:
inode->i_op = &erofs_generic_iops;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
goto out_unlock;
- } else {
+ default:
err = -EFSCORRUPTED;
goto out_unlock;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: using switch-case while checking the inode type.
2019-08-30 9:56 [PATCH] erofs: using switch-case while checking the inode type Pratik Shinde
@ 2019-08-30 11:59 ` Gao Xiang via Linux-erofs
2019-08-30 14:22 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang via Linux-erofs @ 2019-08-30 11:59 UTC (permalink / raw)
To: Pratik Shinde; +Cc: devel, linux-erofs, gregkh
Hi Pratik,
The subject line could be better as '[PATCH v2] xxxxxx'...
On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> while filling the linux inode, using switch-case statement to check
> the type of inode.
> switch-case statement looks more clean here.
>
> Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
I have no problem of this patch, and I will do a test and reply
you "Reviewed-by:" in hours (I'm doing another patchset to resolve
what Christoph suggested again)...
Thanks,
Gao Xiang
> ---
> fs/erofs/inode.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index 80f4fe9..6336cc1 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -190,22 +190,28 @@ static int fill_inode(struct inode *inode, int isdir)
> err = read_inode(inode, data + ofs);
> if (!err) {
> /* setup the new inode */
> - if (S_ISREG(inode->i_mode)) {
> + switch (inode->i_mode & S_IFMT) {
> + case S_IFREG:
> inode->i_op = &erofs_generic_iops;
> inode->i_fop = &generic_ro_fops;
> - } else if (S_ISDIR(inode->i_mode)) {
> + break;
> + case S_IFDIR:
> inode->i_op = &erofs_dir_iops;
> inode->i_fop = &erofs_dir_fops;
> - } else if (S_ISLNK(inode->i_mode)) {
> + break;
> + case S_IFLNK:
> /* by default, page_get_link is used for symlink */
> inode->i_op = &erofs_symlink_iops;
> inode_nohighmem(inode);
> - } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
> - S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
> + break;
> + case S_IFCHR:
> + case S_IFBLK:
> + case S_IFIFO:
> + case S_IFSOCK:
> inode->i_op = &erofs_generic_iops;
> init_special_inode(inode, inode->i_mode, inode->i_rdev);
> goto out_unlock;
> - } else {
> + default:
> err = -EFSCORRUPTED;
> goto out_unlock;
> }
> --
> 2.9.3
>
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: using switch-case while checking the inode type.
2019-08-30 11:59 ` Gao Xiang via Linux-erofs
@ 2019-08-30 14:22 ` Gao Xiang
2019-09-04 2:12 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2019-08-30 14:22 UTC (permalink / raw)
To: Pratik Shinde; +Cc: devel, gregkh, linux-erofs
On Fri, Aug 30, 2019 at 07:59:48PM +0800, Gao Xiang wrote:
> Hi Pratik,
>
> The subject line could be better as '[PATCH v2] xxxxxx'...
>
> On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> > while filling the linux inode, using switch-case statement to check
> > the type of inode.
> > switch-case statement looks more clean here.
> >
> > Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
>
> I have no problem of this patch, and I will do a test and reply
> you "Reviewed-by:" in hours (I'm doing another patchset to resolve
> what Christoph suggested again)...
Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>
Thanks,
Gao Xiang
>
> Thanks,
> Gao Xiang
>
> > ---
> > fs/erofs/inode.c | 18 ++++++++++++------
> > 1 file changed, 12 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> > index 80f4fe9..6336cc1 100644
> > --- a/fs/erofs/inode.c
> > +++ b/fs/erofs/inode.c
> > @@ -190,22 +190,28 @@ static int fill_inode(struct inode *inode, int isdir)
> > err = read_inode(inode, data + ofs);
> > if (!err) {
> > /* setup the new inode */
> > - if (S_ISREG(inode->i_mode)) {
> > + switch (inode->i_mode & S_IFMT) {
> > + case S_IFREG:
> > inode->i_op = &erofs_generic_iops;
> > inode->i_fop = &generic_ro_fops;
> > - } else if (S_ISDIR(inode->i_mode)) {
> > + break;
> > + case S_IFDIR:
> > inode->i_op = &erofs_dir_iops;
> > inode->i_fop = &erofs_dir_fops;
> > - } else if (S_ISLNK(inode->i_mode)) {
> > + break;
> > + case S_IFLNK:
> > /* by default, page_get_link is used for symlink */
> > inode->i_op = &erofs_symlink_iops;
> > inode_nohighmem(inode);
> > - } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
> > - S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
> > + break;
> > + case S_IFCHR:
> > + case S_IFBLK:
> > + case S_IFIFO:
> > + case S_IFSOCK:
> > inode->i_op = &erofs_generic_iops;
> > init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > goto out_unlock;
> > - } else {
> > + default:
> > err = -EFSCORRUPTED;
> > goto out_unlock;
> > }
> > --
> > 2.9.3
> >
> > _______________________________________________
> > devel mailing list
> > devel@linuxdriverproject.org
> > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: using switch-case while checking the inode type.
2019-08-30 14:22 ` Gao Xiang
@ 2019-09-04 2:12 ` Gao Xiang
2019-09-04 6:31 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: Gao Xiang @ 2019-09-04 2:12 UTC (permalink / raw)
To: gregkh; +Cc: devel, linux-erofs
Hi Greg,
On Fri, Aug 30, 2019 at 10:22:33PM +0800, Gao Xiang wrote:
> On Fri, Aug 30, 2019 at 07:59:48PM +0800, Gao Xiang wrote:
> > Hi Pratik,
> >
> > The subject line could be better as '[PATCH v2] xxxxxx'...
> >
> > On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> > > while filling the linux inode, using switch-case statement to check
> > > the type of inode.
> > > switch-case statement looks more clean here.
> > >
> > > Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
> >
> > I have no problem of this patch, and I will do a test and reply
> > you "Reviewed-by:" in hours (I'm doing another patchset to resolve
> > what Christoph suggested again)...
>
> Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>
ping.. could you kindly merge this patch, the following patchset
has dependency on it...
Thanks,
Gao Xiang
>
> Thanks,
> Gao Xiang
>
> >
> > Thanks,
> > Gao Xiang
> >
> > > ---
> > > fs/erofs/inode.c | 18 ++++++++++++------
> > > 1 file changed, 12 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> > > index 80f4fe9..6336cc1 100644
> > > --- a/fs/erofs/inode.c
> > > +++ b/fs/erofs/inode.c
> > > @@ -190,22 +190,28 @@ static int fill_inode(struct inode *inode, int isdir)
> > > err = read_inode(inode, data + ofs);
> > > if (!err) {
> > > /* setup the new inode */
> > > - if (S_ISREG(inode->i_mode)) {
> > > + switch (inode->i_mode & S_IFMT) {
> > > + case S_IFREG:
> > > inode->i_op = &erofs_generic_iops;
> > > inode->i_fop = &generic_ro_fops;
> > > - } else if (S_ISDIR(inode->i_mode)) {
> > > + break;
> > > + case S_IFDIR:
> > > inode->i_op = &erofs_dir_iops;
> > > inode->i_fop = &erofs_dir_fops;
> > > - } else if (S_ISLNK(inode->i_mode)) {
> > > + break;
> > > + case S_IFLNK:
> > > /* by default, page_get_link is used for symlink */
> > > inode->i_op = &erofs_symlink_iops;
> > > inode_nohighmem(inode);
> > > - } else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) ||
> > > - S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
> > > + break;
> > > + case S_IFCHR:
> > > + case S_IFBLK:
> > > + case S_IFIFO:
> > > + case S_IFSOCK:
> > > inode->i_op = &erofs_generic_iops;
> > > init_special_inode(inode, inode->i_mode, inode->i_rdev);
> > > goto out_unlock;
> > > - } else {
> > > + default:
> > > err = -EFSCORRUPTED;
> > > goto out_unlock;
> > > }
> > > --
> > > 2.9.3
> > >
> > > _______________________________________________
> > > devel mailing list
> > > devel@linuxdriverproject.org
> > > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: using switch-case while checking the inode type.
2019-09-04 2:12 ` Gao Xiang
@ 2019-09-04 6:31 ` Greg KH
2019-09-04 7:38 ` Gao Xiang
0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2019-09-04 6:31 UTC (permalink / raw)
To: Gao Xiang; +Cc: devel, linux-erofs
On Wed, Sep 04, 2019 at 10:12:47AM +0800, Gao Xiang wrote:
> Hi Greg,
>
> On Fri, Aug 30, 2019 at 10:22:33PM +0800, Gao Xiang wrote:
> > On Fri, Aug 30, 2019 at 07:59:48PM +0800, Gao Xiang wrote:
> > > Hi Pratik,
> > >
> > > The subject line could be better as '[PATCH v2] xxxxxx'...
> > >
> > > On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> > > > while filling the linux inode, using switch-case statement to check
> > > > the type of inode.
> > > > switch-case statement looks more clean here.
> > > >
> > > > Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
> > >
> > > I have no problem of this patch, and I will do a test and reply
> > > you "Reviewed-by:" in hours (I'm doing another patchset to resolve
> > > what Christoph suggested again)...
> >
> > Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>
>
> ping.. could you kindly merge this patch, the following patchset
> has dependency on it...
Will go do that now, sorry for the delay.
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] erofs: using switch-case while checking the inode type.
2019-09-04 6:31 ` Greg KH
@ 2019-09-04 7:38 ` Gao Xiang
0 siblings, 0 replies; 6+ messages in thread
From: Gao Xiang @ 2019-09-04 7:38 UTC (permalink / raw)
To: Greg KH; +Cc: devel, linux-erofs
On Wed, Sep 04, 2019 at 08:31:34AM +0200, Greg KH wrote:
> On Wed, Sep 04, 2019 at 10:12:47AM +0800, Gao Xiang wrote:
> > Hi Greg,
> >
> > On Fri, Aug 30, 2019 at 10:22:33PM +0800, Gao Xiang wrote:
> > > On Fri, Aug 30, 2019 at 07:59:48PM +0800, Gao Xiang wrote:
> > > > Hi Pratik,
> > > >
> > > > The subject line could be better as '[PATCH v2] xxxxxx'...
> > > >
> > > > On Fri, Aug 30, 2019 at 03:26:15PM +0530, Pratik Shinde wrote:
> > > > > while filling the linux inode, using switch-case statement to check
> > > > > the type of inode.
> > > > > switch-case statement looks more clean here.
> > > > >
> > > > > Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
> > > >
> > > > I have no problem of this patch, and I will do a test and reply
> > > > you "Reviewed-by:" in hours (I'm doing another patchset to resolve
> > > > what Christoph suggested again)...
> > >
> > > Reviewed-by: Gao Xiang <gaoxiang25@huawei.com>
> >
> > ping.. could you kindly merge this patch, the following patchset
> > has dependency on it...
>
> Will go do that now, sorry for the delay.
Thanks Greg...
Thanks,
Gao Xiang
>
> greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-09-04 7:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30 9:56 [PATCH] erofs: using switch-case while checking the inode type Pratik Shinde
2019-08-30 11:59 ` Gao Xiang via Linux-erofs
2019-08-30 14:22 ` Gao Xiang
2019-09-04 2:12 ` Gao Xiang
2019-09-04 6:31 ` Greg KH
2019-09-04 7:38 ` Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).