[PATCH 4/4] fs: btrfs: initialize @ii in show_dir() to make coverity happy

Qu Wenruo wqu at suse.com
Sat Oct 31 02:07:52 CET 2020


In show_dir() if we hit file type FT_CHRDEV or FT_BLKDEV, we expect an
BTRFS_INODE_ITEM_KEY, and for that case, we should have @ii filled with
data read from disk.

We even have ASSERT() for this purpose, but unfortunately coverity can't
understand the ASSERT() nor if we get key type BTRFS_INODE_ITEM_KEY,
previous if() branch must go to the read_extent_buffer() branch to fill
the @ii.

So to make coverity happy, just initialize the variable @ii to all zero.

Reported-by: Coverity CID 312950
Signed-off-by: Qu Wenruo <wqu at suse.com>
---
 fs/btrfs/btrfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
index 346b2c4341c2..1abd2c291177 100644
--- a/fs/btrfs/btrfs.c
+++ b/fs/btrfs/btrfs.c
@@ -19,7 +19,7 @@ static int show_dir(struct btrfs_root *root, struct extent_buffer *eb,
 		    struct btrfs_dir_item *di)
 {
 	struct btrfs_fs_info *fs_info = root->fs_info;
-	struct btrfs_inode_item ii;
+	struct btrfs_inode_item ii = { 0 };
 	struct btrfs_key key;
 	static const char* dir_item_str[] = {
 		[BTRFS_FT_REG_FILE]	= "FILE",
-- 
2.29.1



More information about the U-Boot mailing list