Skip to contentSkip to conversation

fat: silence warning for 64KB PAGE_SIZE builds

PATCH In review Olof Johansson 2 participants 4 messages Nov 7, 2007 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fat: silence warning for 64KB PAGE_SIZE builds

Annoying gcc warning:

fs/fat/inode.c: In function 'fat_fill_super':
fs/fat/inode.c:1222: warning: comparison is always false due to limited range of data type

logical_sector_size can never be more than 16 bits worth, but switching it to an int silences gcc. It's a sanity check that can never fail with 64KB PAGE_SIZE but it seems like it'd still be useful for other page sizes, so it's worth keeping:

        if (!is_power_of_2(logical_sector_size)
            || (logical_sector_size < 512)
            || (PAGE_CACHE_SIZE < logical_sector_size)) {
                if (!silent)
                        printk(KERN_ERR "FAT: bogus logical sector size %u\n",
                               logical_sector_size);
                brelse(bh);
                goto out_invalid;
        }
fs/fat/inode.c +1 -1
index 920a576..6aae680 100644
@@ -1158,7 +1158,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
 	struct buffer_head *bh;
 	struct fat_boot_sector *b;
 	struct msdos_sb_info *sbi;
-	u16 logical_sector_size;
+	int logical_sector_size;
 	u32 total_sectors, total_clusters, fat_clusters, rootdir_sectors;
 	int debug;
 	unsigned int media;
maintainer
#1 lore raw
Quoted 5 lines · Olof Johansson

logical_sector_size can never be more than 16 bits worth, but switching it to an int silences gcc. It's a sanity check that can never fail with 64KB PAGE_SIZE but it seems like it'd still be useful for other page sizes, so it's worth keeping:

Quoted 9 lines
        if (!is_power_of_2(logical_sector_size)
            || (logical_sector_size < 512)
            || (PAGE_CACHE_SIZE < logical_sector_size)) {
                if (!silent)
                        printk(KERN_ERR "FAT: bogus logical sector size %u\n",
                               logical_sector_size);
                brelse(bh);
                goto out_invalid;
        }

Please use 4096 instead of allowing it, at least for now.

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#2 lore raw

Annoying gcc warning:

fs/fat/inode.c: In function 'fat_fill_super':
fs/fat/inode.c:1222: warning: comparison is always false due to limited range of data type

Change it to compare with 4K instead of PAGE_CACHE_SIZE, as suggested by OGAWA-san.

---

Quoted 6 lines · OGAWA Hirofumi
Quoted 4 lines · Olof Johansson

logical_sector_size can never be more than 16 bits worth, but switching it to an int silences gcc. It's a sanity check that can never fail with 64KB PAGE_SIZE but it seems like it'd still be useful for other page sizes, so it's worth keeping:

[...]

Quoted 2 lines

Please use 4096 instead of allowing it, at least for now.

Sure. New patch.

Thanks,

-Olof

fs/fat/inode.c +1 -1
index 920a576..61e2874 100644
@@ -1219,7 +1219,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
 		le16_to_cpu(get_unaligned((__le16 *)&b->sector_size));
 	if (!is_power_of_2(logical_sector_size)
 	    || (logical_sector_size < 512)
-	    || (PAGE_CACHE_SIZE < logical_sector_size)) {
+	    || (logical_sector_size > 4096)) {
 		if (!silent)
 			printk(KERN_ERR "FAT: bogus logical sector size %u\n",
 			       logical_sector_size);
maintainer Acked-by
#3 lore raw
Quoted 36 lines · Olof Johansson

Annoying gcc warning:

fs/fat/inode.c: In function 'fat_fill_super':
fs/fat/inode.c:1222: warning: comparison is always false due to limited range of data type

Change it to compare with 4K instead of PAGE_CACHE_SIZE, as suggested by OGAWA-san.

---

Quoted 6 lines · OGAWA Hirofumi
Quoted 4 lines · Olof Johansson

logical_sector_size can never be more than 16 bits worth, but switching it to an int silences gcc. It's a sanity check that can never fail with 64KB PAGE_SIZE but it seems like it'd still be useful for other page sizes, so it's worth keeping:

[...]

Quoted 2 lines

Please use 4096 instead of allowing it, at least for now.

Sure. New patch.

Thanks,

(quoted diff) +0 -1
-Olof
fs/fat/inode.c +0 -0
index 920a576..61e2874 100644

fs/fat/inode.c int fat_fill_super(struct super_block *sb, void *data, int silent, · line 1225

Quoted 8 lines
fs/fat/inode.c +1 -1
@@ -1219,7 +1219,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
 		le16_to_cpu(get_unaligned((__le16 *)&b->sector_size));
 	if (!is_power_of_2(logical_sector_size)
 	    || (logical_sector_size < 512)
-	    || (PAGE_CACHE_SIZE < logical_sector_size)) {
+	    || (logical_sector_size > 4096)) {
 		if (!silent)
 			printk(KERN_ERR "FAT: bogus logical sector size %u\n",
 			       logical_sector_size);

Thanks a lot.

Signature · 1 line
OGAWA Hirofumi <[email protected]>