Commit 3c91ee69 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David Sterba

Btrfs: work around maybe-uninitialized warning

A rewrite of btrfs_submit_direct_hook appears to have introduced a warning:

fs/btrfs/inode.c: In function 'btrfs_submit_direct_hook':
fs/btrfs/inode.c:8467:14: error: 'bio' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Where the 'bio' variable was previously initialized unconditionally, it
is now set in the "while (submit_len > 0)" loop that would never execute
if submit_len is zero.

Assuming this cannot happen in practice, we can avoid the warning
by simply replacing the while{} loop with a do{}while() loop so
the compiler knows that it will always be entered at least once.

Fixes changes introduced in "Btrfs: use bio_clone_bioset_partial to
simplify DIO submit".
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 3892ac90
...@@ -8507,7 +8507,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, ...@@ -8507,7 +8507,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
/* bio split */ /* bio split */
ASSERT(map_length <= INT_MAX); ASSERT(map_length <= INT_MAX);
atomic_inc(&dip->pending_bios); atomic_inc(&dip->pending_bios);
while (submit_len > 0) { do {
clone_len = min_t(int, submit_len, map_length); clone_len = min_t(int, submit_len, map_length);
/* /*
...@@ -8550,7 +8550,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip, ...@@ -8550,7 +8550,7 @@ static int btrfs_submit_direct_hook(struct btrfs_dio_private *dip,
start_sector << 9, &map_length, NULL, 0); start_sector << 9, &map_length, NULL, 0);
if (ret) if (ret)
goto out_err; goto out_err;
} } while (submit_len > 0);
submit: submit:
ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum, ret = __btrfs_submit_dio_bio(bio, inode, file_offset, skip_sum,
......
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