From: Jens Axboe <axboe@kernel.dk>
To: Nathan Chancellor <nathan@kernel.org>, Jens Axboe <axboe@fb.com>,
Christoph Hellwig <hch@lst.de>, Keith Busch <kbusch@kernel.org>,
Sagi Grimberg <sagi@grimberg.me>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
Tom Rix <trix@redhat.com>, Kanchan Joshi <joshi.k@samsung.com>,
Anuj Gupta <anuj20.g@samsung.com>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] nvme: Ensure ret is always initialized in
Date: Fri, 6 May 2022 09:09:41 -0600 [thread overview]
Message-ID: <4a87c2d9-89fa-2cec-7707-08fc78c88bf8@kernel.dk> (raw)
In-Reply-To: <20220506150357.2443040-1-nathan@kernel.org>
On 5/6/22 9:03 AM, Nathan Chancellor wrote:
> Clang warns:
>
> drivers/nvme/host/ioctl.c:674:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> if (ns)
> ^~
> drivers/nvme/host/ioctl.c:677:9: note: uninitialized use occurs here
> return ret;
> ^~~
> drivers/nvme/host/ioctl.c:674:2: note: remove the 'if' if its condition is always true
> if (ns)
> ^~~~~~~
> drivers/nvme/host/ioctl.c:672:9: note: initialize the variable 'ret' to silence this warning
> int ret;
> ^
> = 0
> 1 error generated.
>
> Initialize ret to zero so that it cannot be used uninitialized.
Thanks, will fold this in.
> Or alternatively, remove the 'if (ns)' if ns can never be NULL; I tried
> going down the rabbit hole to see if that is possible but I got a little
> lost :^)
For the admin queue, ns can be NULL.
--
Jens Axboe
prev parent reply other threads:[~2022-05-06 15:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 15:03 [PATCH] nvme: Ensure ret is always initialized in Nathan Chancellor
2022-05-06 15:06 ` Nathan Chancellor
2022-05-06 15:09 ` Jens Axboe [this message]
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=4a87c2d9-89fa-2cec-7707-08fc78c88bf8@kernel.dk \
--to=axboe@kernel.dk \
--cc=anuj20.g@samsung.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=joshi.k@samsung.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=lkp@intel.com \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=sagi@grimberg.me \
--cc=trix@redhat.com \
/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