[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190322140753.286171-1-arnd@arndb.de>
Date: Fri, 22 Mar 2019 15:07:47 +0100
From: Arnd Bergmann <arnd@...db.de>
To: Chris Mason <clm@...com>, Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>
Cc: clang-built-linux@...glegroups.com,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nathan Chancellor <natechancellor@...il.com>,
Arnd Bergmann <arnd@...db.de>,
Nikolay Borisov <nborisov@...e.com>,
Lu Fengqi <lufq.fnst@...fujitsu.com>,
Anand Jain <anand.jain@...cle.com>,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] btrfs: work around false-positive -Wsometimes-uninitialized warning
clang fails to see that the last 'else if() in btrfs_uuid_tree_add()
is always true, so 'eb' is always initialized correctly:
fs/btrfs/uuid-tree.c:129:13: error: variable 'eb' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
} else if (ret < 0) {
^~~~~~~
fs/btrfs/uuid-tree.c:139:22: note: uninitialized use occurs here
write_extent_buffer(eb, &subid_le, offset, sizeof(subid_le));
^~
fs/btrfs/uuid-tree.c:129:9: note: remove the 'if' if its condition is always true
} else if (ret < 0) {
^~~~~~~~~~~~~
fs/btrfs/uuid-tree.c:90:26: note: initialize the variable 'eb' to silence this warning
struct extent_buffer *eb;
^
= NULL
Change it into a plain 'else' to shut up that warning.
Link: https://bugs.llvm.org/show_bug.cgi?id=41197
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
fs/btrfs/uuid-tree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
index 3b2ae342e649..c1cc9a5c0024 100644
--- a/fs/btrfs/uuid-tree.c
+++ b/fs/btrfs/uuid-tree.c
@@ -126,7 +126,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
slot = path->slots[0];
offset = btrfs_item_ptr_offset(eb, slot);
offset += btrfs_item_size_nr(eb, slot) - sizeof(subid_le);
- } else if (ret < 0) {
+ } else {
btrfs_warn(fs_info,
"insert uuid item failed %d (0x%016llx, 0x%016llx) type %u!",
ret, (unsigned long long)key.objectid,
--
2.20.0
Powered by blists - more mailing lists