Skip to contentSkip to conversation

befs: befs_fill_super(): remove unreachable code

PATCH NAK Tim Gardner 2 participants 3 messages Feb 12, 2013 Befs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 befs: befs_fill_super(): remove unreachable code

befs_sb->num_blocks is of base type u64 which is the same as sector_t. Therefore, num_blocks can never be larger then the maximum value of sector_t.

smatch analysis:

fs/befs/linuxvfs.c:851 befs_fill_super() warn: impossible
condition '(befs_sb->num_blocks > ~(0)) => (0-u64max > u64max)'

Cc Al Viro <[email protected]>
Cc Andrew Morton <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
---
 fs/befs/linuxvfs.c |    7 -------
 1 file changed, 7 deletions(-)
fs/befs/linuxvfs.c +0 -7
index 2b3bda8..2ce5705 100644
@@ -848,13 +848,6 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
 	if (befs_check_sb(sb) != BEFS_OK)
 		goto unacquire_priv_sbp;
 
-	if( befs_sb->num_blocks > ~((sector_t)0) ) {
-		befs_error(sb, "blocks count: %Lu "
-			"is larger than the host can use",
-			befs_sb->num_blocks);
-		goto unacquire_priv_sbp;
-	}
-
 	/*
 	 * set up enough so that it can read an inode
 	 * Fill in kernel superblock fields from private sb
Signature · 1 line
1.7.9.5
Nacked-by on v1 1/1 NAK
#1 lore raw
Quoted 3 lines · Tim Gardner

befs_sb->num_blocks is of base type u64 which is the same as sector_t. Therefore, num_blocks can never be larger then the maximum value of sector_t.

The analysys is wrong. On 32bit with CONFIG_LBAF unset sector_t is an unsigned long aka a u32, while befs_off_t is always a u64.

Quoted 32 lines

smatch analysis:

fs/befs/linuxvfs.c:851 befs_fill_super() warn: impossible
condition '(befs_sb->num_blocks > ~(0)) => (0-u64max > u64max)'

Cc Al Viro <[email protected]>
Cc Andrew Morton <[email protected]>
Cc "Eric W. Biederman" <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
---
 fs/befs/linuxvfs.c |    7 -------
 1 file changed, 7 deletions(-)
fs/befs/linuxvfs.c +0 -7
index 2b3bda8..2ce5705 100644
@@ -848,13 +848,6 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
 	if (befs_check_sb(sb) != BEFS_OK)
 		goto unacquire_priv_sbp;
 
-	if( befs_sb->num_blocks > ~((sector_t)0) ) {
-		befs_error(sb, "blocks count: %Lu "
-			"is larger than the host can use",
-			befs_sb->num_blocks);
-		goto unacquire_priv_sbp;
-	}
-
 	/*
 	 * set up enough so that it can read an inode
 	 * Fill in kernel superblock fields from private sb
#2 lore raw
Quoted 10 lines · Eric W. Biederman
Quoted 3 lines · Tim Gardner

befs_sb->num_blocks is of base type u64 which is the same as sector_t. Therefore, num_blocks can never be larger then the maximum value of sector_t.

The analysys is wrong. On 32bit with CONFIG_LBAF unset sector_t is an unsigned long aka a u32, while befs_off_t is always a u64.

Dang - you're right.

Signature · 1 line
Tim Gardner [email protected]