From: Joe Perches <joe@perches.com>
To: Carmeli Tamir <carmeli.tamir@gmail.com>,
hirofumi@mail.parknet.co.jp, jthumshirn@suse.de,
sergey.senozhatsky@gmail.com, akpm@linux-foundation.org,
axboe@kernel.dk, martin.petersen@oracle.com, bvanassche@acm.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] fat: New macros to determine the FAT variant (32, 16 or 12)
Date: Mon, 10 Dec 2018 12:09:31 -0800 [thread overview]
Message-ID: <906167f7ca975d437ff9868333d8bf1e86b934a7.camel@perches.com> (raw)
In-Reply-To: <1544470917-6443-3-git-send-email-carmeli.tamir@gmail.com>
On Mon, 2018-12-10 at 14:41 -0500, Carmeli Tamir wrote:
> This patch introduces 3 new macros - IS_FAT12, IS_FAT16 and IS_FAT32,
> and replaces every occurrence in the code in which the FS variant (whether
> this is FAT12, FAT16 or FAT32) was previously checked using
> msdos_sb_info->fat_bits.
Overall a nice cleanup and a couple style suggestions:
> diff --git a/fs/fat/cache.c b/fs/fat/cache.c
> index 78d501c..99962b3 100644
> --- a/fs/fat/cache.c
> +++ b/fs/fat/cache.c
> @@ -363,7 +363,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
>
> *phys = 0;
> *mapped_blocks = 0;
> - if ((sbi->fat_bits != 32) && (inode->i_ino == MSDOS_ROOT_INO)) {
> + if ((!IS_FAT32(sbi)) && (inode->i_ino == MSDOS_ROOT_INO)) {
Perhaps nicer without the parens around !IS_FAT32(sbi)
[]
> diff --git a/fs/fat/fat.h b/fs/fat/fat.h
[]
> @@ -116,12 +116,16 @@ static inline struct msdos_sb_info *MSDOS_SB(struct super_block *sb)
> * this is FAT12, FAT16 or FAT32.
> */
>
> -#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
> - MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))
> +#define IS_FAT12(sbi) (sbi->fat_bits == 12)
> +#define IS_FAT16(sbi) (sbi->fat_bits == 16)
> +#define IS_FAT32(sbi) (sbi->fat_bits == 32)
sbi should be parenthesized or perhaps better these should be
static inline bool functions
> +
> +#define FAT_FIRST_ENT(s, x) ((IS_FAT32(MSDOS_SB(s)) ? 0x0FFFFF00 : \
> + IS_FAT16(MSDOS_SB(s)) ? 0xFF00 : 0xF00) | (x))
This is probably nicer to use a statement expression macro
so MSDOS_SB(s) is only evaluated once or convert this to a
static inline, but it may even better to remove it altogether
instead as it seems unused anywhere.
>
> /* maximum number of clusters */
> -#define MAX_FAT(s) (MSDOS_SB(s)->fat_bits == 32 ? MAX_FAT32 : \
> - MSDOS_SB(s)->fat_bits == 16 ? MAX_FAT16 : MAX_FAT12)
> +#define MAX_FAT(s) (IS_FAT32(MSDOS_SB(s)) ? MAX_FAT32 : \
> + IS_FAT16(MSDOS_SB(s)) ? MAX_FAT16 : MAX_FAT12)
Used once, so perhaps better inlined there.
next prev parent reply other threads:[~2018-12-10 20:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 19:41 [PATCH 0/2] fat: Added macros to determine the FAT FS variant (12/16/32bit) Carmeli Tamir
2018-12-10 19:41 ` [PATCH 1/2] fat: Moved macros that won't work without fat.h Carmeli Tamir
2018-12-10 19:41 ` [PATCH 2/2] fat: New macros to determine the FAT variant (32, 16 or 12) Carmeli Tamir
2018-12-10 20:09 ` Joe Perches [this message]
2018-12-14 3:16 ` OGAWA Hirofumi
2018-12-14 8:14 ` Tamir Carmeli
2018-12-14 9:49 ` OGAWA Hirofumi
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=906167f7ca975d437ff9868333d8bf1e86b934a7.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=carmeli.tamir@gmail.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=jthumshirn@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sergey.senozhatsky@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®