All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Marek Behún" <marek.behun@nic.cz>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables
Date: Fri,  6 Oct 2017 15:04:57 +0200	[thread overview]
Message-ID: <20171006130459.29127-2-marek.behun@nic.cz> (raw)
In-Reply-To: <20171006130459.29127-1-marek.behun@nic.cz>

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 | 2 +-
 fs/btrfs/dir-item.c  | 2 +-
 fs/btrfs/inode.c     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/chunk-map.c b/fs/btrfs/chunk-map.c
index 48407f3331..ce7330b1b7 100644
--- a/fs/btrfs/chunk-map.c
+++ b/fs/btrfs/chunk-map.c
@@ -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;
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index decf86eb53..970563404f 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -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;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 0d3da28296..0af04278a3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -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;
-- 
2.13.6

  reply	other threads:[~2017-10-06 13:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06 13:04 [U-Boot] [PATCH 1/4] linux/time.h: Remove dead code Marek Behún
2017-10-06 13:04 ` Marek Behún [this message]
     [not found]   ` <99f56d19-544c-4604-4f82-bd7a9a1e45b6@comcast.net>
2017-10-06 14:28     ` [U-Boot] [PATCH 2/4] fs: btrfs: Fix usage of uninitialized variables Marek Behún
2017-10-17  0:47   ` [U-Boot] [U-Boot, " Tom Rini
2017-10-06 13:04 ` [U-Boot] [PATCH 3/4] fs: btrfs: Fix printf length modifier Marek Behún
2017-10-06 13:14   ` Marek Behún
2017-10-06 14:23     ` Tom Rini
2017-10-06 13:04 ` [U-Boot] [PATCH 4/4] fs: btrfs: Remove a foreign language note Marek Behún
2017-10-17  0:47   ` [U-Boot] [U-Boot, " Tom Rini
2017-10-17  0:47 ` [U-Boot] [U-Boot,1/4] linux/time.h: Remove dead code Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171006130459.29127-2-marek.behun@nic.cz \
    --to=marek.behun@nic.cz \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.