From: Phillip Potter <phil@philpotter.co.uk>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: dushistov@mail.ru, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: ufs: Convert ufs_set_de_type to use lookup table
Date: Tue, 2 Oct 2018 09:31:00 +0100 [thread overview]
Message-ID: <20181002083100.GB4263@pathfinder> (raw)
In-Reply-To: <20181002022814.GN32577@ZenIV.linux.org.uk>
On Tue, Oct 02, 2018 at 03:28:14AM +0100, Al Viro wrote:
> On Mon, Oct 01, 2018 at 04:33:10PM +0100, Phillip Potter wrote:
> > Modify ufs_set_de_type function in fs/ufs/util.h to use a lookup
> > table rather than a switch statement, as per the TODO comment.
>
> Brittle, that... Something like fs/ext2/dir.c approach (that is,
> #define S_SHIFT 12
> static unsigned char ext2_type_by_mode[S_IFMT >> S_SHIFT] = {
> [S_IFREG >> S_SHIFT] = EXT2_FT_REG_FILE,
> [S_IFDIR >> S_SHIFT] = EXT2_FT_DIR,
> [S_IFCHR >> S_SHIFT] = EXT2_FT_CHRDEV,
> [S_IFBLK >> S_SHIFT] = EXT2_FT_BLKDEV,
> [S_IFIFO >> S_SHIFT] = EXT2_FT_FIFO,
> [S_IFSOCK >> S_SHIFT] = EXT2_FT_SOCK,
> [S_IFLNK >> S_SHIFT] = EXT2_FT_SYMLINK,
> };
> in there) would be saner, IMO. Note that DT_UNKNOWN is zero, so the
> array elements lacking an explicit initializer will end up with that.
>
> What's more, the values are ->i_mode >> 12 or 0, depending upon the
> value being valid. And since the upper layers do validate the type,
> I'd consider simply using (inode->i_mode & S_IFMT) >> 12 there.
> Unlike ext2, ufs stores straight bits 12..15 there (ext2 uses an
> enum with sequential values instead; e.g. regular files are encoded
> as 1 there, not 8 as on ufs)...
Dear Al,
Thank you for taking time to offer your feedback, I really appreciate
it. I will rework this patch this evening and resubmit.
Regards,
Phil
next prev parent reply other threads:[~2018-10-02 8:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 15:33 [PATCH] fs: ufs: Convert ufs_set_de_type to use lookup table Phillip Potter
2018-10-02 2:28 ` Al Viro
2018-10-02 8:31 ` Phillip Potter [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-04-03 8:59 Phillip Potter
2018-03-18 20:56 Phillip Potter
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=20181002083100.GB4263@pathfinder \
--to=phil@philpotter.co.uk \
--cc=dushistov@mail.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 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).