Skip to content

Commit

Permalink
btrfs: shut up bogus -Wmaybe-uninitialized warning
Browse files Browse the repository at this point in the history
gcc sometimes can't determine whether a variable has been initialized
when both the initialization and the use are conditional:

fs/btrfs/props.c: In function 'inherit_props':
fs/btrfs/props.c:389:4: error: 'num_bytes' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    btrfs_block_rsv_release(fs_info, trans->block_rsv,

This code is fine. Unfortunately, I cannot think of a good way to
rephrase it in a way that makes gcc understand this, so I add a bogus
initialization the way one should not.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: David Sterba <dsterba@suse.com>
[ gcc 8 and 9 don't emit the warning ]
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Arnd Bergmann authored and David Sterba committed Jul 2, 2019
1 parent 9e96749 commit 6c64460
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/props.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ static int inherit_props(struct btrfs_trans_handle *trans,
for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) {
const struct prop_handler *h = &prop_handlers[i];
const char *value;
u64 num_bytes;
u64 num_bytes = 0;

if (!h->inheritable)
continue;
Expand Down

0 comments on commit 6c64460

Please sign in to comment.