Commit e952813e authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Jan Kara

ext2: avoid bogus -Wmaybe-uninitialized warning

On ARM, we get this false-positive warning since the rework of
the ext2_get_blocks interface:

fs/ext2/inode.c: In function 'ext2_get_block':
include/linux/buffer_head.h:340:16: error: 'bno' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The calling conventions for this function are rather complex, and it's
not surprising that the compiler gets this wrong, I spent a long time
trying to understand how it all fits together myself.

This change to avoid the warning makes sure the compiler sees that we
always set 'bno' pointer whenever we have a positive return code.
The transformation is correct because we always arrive at the 'got_it'
label with a positive count that gets used as the return value, while
any branch to the 'cleanup' label has a negative or zero 'err'.

Fixes: 6750ad71 ("ext2: stop passing buffer_head to ext2_get_blocks")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent a2ed0b39
...@@ -622,7 +622,7 @@ static int ext2_get_blocks(struct inode *inode, ...@@ -622,7 +622,7 @@ static int ext2_get_blocks(struct inode *inode,
u32 *bno, bool *new, bool *boundary, u32 *bno, bool *new, bool *boundary,
int create) int create)
{ {
int err = -EIO; int err;
int offsets[4]; int offsets[4];
Indirect chain[4]; Indirect chain[4];
Indirect *partial; Indirect *partial;
...@@ -639,7 +639,7 @@ static int ext2_get_blocks(struct inode *inode, ...@@ -639,7 +639,7 @@ static int ext2_get_blocks(struct inode *inode,
depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary); depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary);
if (depth == 0) if (depth == 0)
return (err); return -EIO;
partial = ext2_get_branch(inode, depth, offsets, chain, &err); partial = ext2_get_branch(inode, depth, offsets, chain, &err);
/* Simplest case - block found, no allocation needed */ /* Simplest case - block found, no allocation needed */
...@@ -761,7 +761,6 @@ static int ext2_get_blocks(struct inode *inode, ...@@ -761,7 +761,6 @@ static int ext2_get_blocks(struct inode *inode,
ext2_splice_branch(inode, iblock, partial, indirect_blks, count); ext2_splice_branch(inode, iblock, partial, indirect_blks, count);
mutex_unlock(&ei->truncate_mutex); mutex_unlock(&ei->truncate_mutex);
got_it: got_it:
*bno = le32_to_cpu(chain[depth-1].key);
if (count > blocks_to_boundary) if (count > blocks_to_boundary)
*boundary = true; *boundary = true;
err = count; err = count;
...@@ -772,6 +771,8 @@ static int ext2_get_blocks(struct inode *inode, ...@@ -772,6 +771,8 @@ static int ext2_get_blocks(struct inode *inode,
brelse(partial->bh); brelse(partial->bh);
partial--; partial--;
} }
if (err > 0)
*bno = le32_to_cpu(chain[depth-1].key);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment