From: Gao Xiang <gaoxiang25@huawei.com>
To: Pratik Shinde <pratikshinde320@gmail.com>
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] staging: erofs: using switch-case while checking the inode type.
Date: Thu, 29 Aug 2019 22:15:22 +0800 [thread overview]
Message-ID: <20190829141522.GA15562@architecture4> (raw)
In-Reply-To: <CAGu0czRasWHj53uF5zAoDRjbxU2sgN6HtazN_9Y-mkK6NjO-LQ@mail.gmail.com>
On Thu, Aug 29, 2019 at 07:35:01PM +0530, Pratik Shinde wrote:
> Hi Gao,
>
> Sorry I didn't pull the latest tree. I will do the necessary.
> Anyways, don't you think it will be cleaner to have a switch case statement
> rather than if-else statement.
I think so, but that's another personal choise and no urgent
as well (It is just a cleanup to some extent).
I am very happy that you send a patch about this, but we have
to take care of handling "fall through" properly at least,
and I don't want to introduce some extra compile warnings
instead at this time.
EROFS is sensitive for now and I have no idea what the "real"
point is.
Thanks,
Gao Xiang
>
> --Pratik
>
>
>
> On Thu, 29 Aug, 2019, 7:27 PM Gao Xiang, <gaoxiang25@huawei.com> wrote:
>
> > Hi Pratik,
> >
> > On Thu, Aug 29, 2019 at 06:38:13PM +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.
> > >
> > > Signed-off-by: Pratik Shinde <pratikshinde320@gmail.com>
> >
> > No, that is not the case, see __ext4_iget() in fs/ext4/inode.c.
> > and could you write patches based on latest staging tree?
> > erofs is now in "fs/" rather than "drivers/staging".
> > and I will review it then.
> >
> > p.s. if someone argues here or there, there will be endless
> > issues since there is no standard at all.
> >
> > Thanks,
> > Gao Xiang
> >
> > > ---
> > > drivers/staging/erofs/inode.c | 18 ++++++++++++------
> > > 1 file changed, 12 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/staging/erofs/inode.c
> > b/drivers/staging/erofs/inode.c
> > > index 4c3d8bf..2d2d545 100644
> > > --- a/drivers/staging/erofs/inode.c
> > > +++ b/drivers/staging/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 = -EIO;
> > > goto out_unlock;
> > > }
> > > --
> > > 2.9.3
> > >
> >
next prev parent reply other threads:[~2019-08-29 14:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-29 13:08 [PATCH] staging: erofs: using switch-case while checking the inode type Pratik Shinde
2019-08-29 13:56 ` Gao Xiang
2019-08-29 14:05 ` Pratik Shinde
2019-08-29 14:15 ` Gao Xiang [this message]
2019-08-29 15:04 ` Dan Carpenter
2019-08-29 15:13 ` Gao Xiang
2019-08-29 18:57 ` Gao Xiang via Linux-erofs
2019-08-29 15:00 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190829141522.GA15562@architecture4 \
--to=gaoxiang25@huawei.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=pratikshinde320@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.