From: Brooke Basile <brookebasile@gmail.com>
To: danil.kipnis@cloud.ionos.com, jinpu.wang@cloud.ionos.com,
axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
clang-built-linux@googlegroups.com,
Brooke Basile <brookebasile@gmail.com>
Subject: [PATCH] block: rnbd: rnbd-srv: silence uninitialized variable warning
Date: Tue, 18 Aug 2020 00:03:18 -0400 [thread overview]
Message-ID: <20200818040317.5926-1-brookebasile@gmail.com> (raw)
Clang warns:
drivers/block/rnbd/rnbd-srv.c:150:6: warning: variable 'err' is used
uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (IS_ERR(bio)) {
^~~~~~~~~~~
drivers/block/rnbd/rnbd-srv.c:177:9: note: uninitialized use occurs here
return err;
^~~
drivers/block/rnbd/rnbd-srv.c:126:9: note: initialize the variable 'err'
to silence this warning
int err;
^
= 0
Silence this by replacing `err` with `ret`, returning ret = 0 upon
success.
Signed-off-by: Brooke Basile <brookebasile@gmail.com>
---
drivers/block/rnbd/rnbd-srv.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c
index 0fb94843a495..f515d1a048a9 100644
--- a/drivers/block/rnbd/rnbd-srv.c
+++ b/drivers/block/rnbd/rnbd-srv.c
@@ -123,10 +123,10 @@ static int process_rdma(struct rtrs_srv *sess,
struct rnbd_io_private *priv;
struct rnbd_srv_sess_dev *sess_dev;
u32 dev_id;
- int err;
struct rnbd_dev_blk_io *io;
struct bio *bio;
short prio;
+ int ret = 0;
priv = kmalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -138,7 +138,7 @@ static int process_rdma(struct rtrs_srv *sess,
if (IS_ERR(sess_dev)) {
pr_err_ratelimited("Got I/O request on session %s for unknown device id %d\n",
srv_sess->sessname, dev_id);
- err = -ENOTCONN;
+ ret = -ENOTCONN;
goto err;
}
@@ -168,13 +168,13 @@ static int process_rdma(struct rtrs_srv *sess,
submit_bio(bio);
- return 0;
+ return ret;
sess_dev_put:
rnbd_put_sess_dev(sess_dev);
err:
kfree(priv);
- return err;
+ return ret;
}
static void destroy_device(struct rnbd_srv_dev *dev)
--
2.28.0
next reply other threads:[~2020-08-18 4:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 4:03 Brooke Basile [this message]
2020-08-18 5:29 ` [PATCH] block: rnbd: rnbd-srv: silence uninitialized variable warning Nathan Chancellor
2020-08-18 6:42 ` Jinpu Wang
2020-08-18 6:49 ` [PATCH] block/rnbd: Ensure err is always initialized in process_rdma Nathan Chancellor
2020-08-18 6:55 ` Jinpu Wang
2020-08-18 14:49 ` Jens Axboe
2020-08-18 12:43 ` [PATCH] block: rnbd: rnbd-srv: silence uninitialized variable warning Brooke Basile
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=20200818040317.5926-1-brookebasile@gmail.com \
--to=brookebasile@gmail.com \
--cc=axboe@kernel.dk \
--cc=clang-built-linux@googlegroups.com \
--cc=danil.kipnis@cloud.ionos.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).