fs: btrfs: Fix usage of uninitialized variables

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>
This commit is contained in:
Marek Behún 2017-10-06 15:04:57 +02:00 committed by Tom Rini
parent 502af618ec
commit ecab881c7f
3 changed files with 3 additions and 3 deletions

View 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;

View 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;

View 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;