]> git.sur5r.net Git - u-boot/commitdiff
fs: btrfs: Fix usage of uninitialized variables
authorMarek BehĂșn <marek.behun@nic.cz>
Fri, 6 Oct 2017 13:04:57 +0000 (15:04 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 16 Oct 2017 13:42:51 +0000 (09:42 -0400)
The variable res should be initialized to 0 in these functions,
because if the searched key is not found, the variable is used
uninitialized.

Reported-by: Coverity (CID: 167335)
Reported-by: Coverity (CID: 167336)
Reported-by: Coverity (CID: 167337)
Signed-off-by: Marek Behun <marek.behun@nic.cz>
fs/btrfs/chunk-map.c
fs/btrfs/dir-item.c
fs/btrfs/inode.c

index 48407f33316f68d8c63578683b9226a372306f33..ce7330b1b77202e1c22ea95bce4938a080a69d01 100644 (file)
@@ -147,7 +147,7 @@ int btrfs_read_chunk_tree(void)
        struct btrfs_path path;
        struct btrfs_key key, *found_key;
        struct btrfs_chunk *chunk;
-       int res;
+       int res = 0;
 
        key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
        key.type = BTRFS_CHUNK_ITEM_KEY;
index decf86eb53eb8b54a0ac3cb1196a471cb5ad9150..970563404fe76b8adb68fc7b08dd8eeae66df142 100644 (file)
@@ -93,7 +93,7 @@ int btrfs_readdir(const struct btrfs_root *root, u64 dir,
        struct btrfs_path path;
        struct btrfs_key key, *found_key;
        struct btrfs_dir_item *item;
-       int res;
+       int res = 0;
 
        key.objectid = dir;
        key.type = BTRFS_DIR_INDEX_KEY;
index 0d3da282966176765cdf592610dee5f654dda4da..0af04278a3c4c84a76e53d965e4bb2dee9257043 100644 (file)
@@ -324,7 +324,7 @@ u64 btrfs_file_read(const struct btrfs_root *root, u64 inr, u64 offset,
        struct btrfs_path path;
        struct btrfs_key key;
        struct btrfs_file_extent_item *extent;
-       int res;
+       int res = 0;
        u64 rd, rd_all = -1ULL;
 
        key.objectid = inr;