Skip to content

Commit

Permalink
FAT_VALID_MEDIA(): remove pointless test
Browse files Browse the repository at this point in the history
The on-disk media specification field in FAT is only 8-bits, so testing for
<=0xff is pointless, and can generate a "comparison is always true due to
limited range of data type" warning.

While we're there, convert FAT_VALID_MEDIA() into a C function - the present
implementation is buggy: it generates either one or two references to its
argument.

Cc: Frank Seidel <[email protected]>
Acked-by: OGAWA Hirofumi <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
akpm00 authored and torvalds committed Apr 28, 2008
1 parent c7a6c4e commit 73f20e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/fat/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
*/

media = b->media;
if (!FAT_VALID_MEDIA(media)) {
if (!fat_valid_media(media)) {
if (!silent)
printk(KERN_ERR "FAT: invalid media value (0x%02x)\n",
media);
Expand Down
6 changes: 5 additions & 1 deletion include/linux/msdos_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
#define MSDOS_DOTDOT ".. " /* "..", padded to MSDOS_NAME chars */

/* media of boot sector */
#define FAT_VALID_MEDIA(x) ((0xF8 <= (x) && (x) <= 0xFF) || (x) == 0xF0)
static inline int fat_valid_media(u8 media)
{
return 0xf8 <= media || media == 0xf0;
}

#define FAT_FIRST_ENT(s, x) ((MSDOS_SB(s)->fat_bits == 32 ? 0x0FFFFF00 : \
MSDOS_SB(s)->fat_bits == 16 ? 0xFF00 : 0xF00) | (x))

Expand Down

0 comments on commit 73f20e5

Please sign in to comment.