[PATCH] nvme: Ensure ret is always initialized in
Jens Axboe
axboe at kernel.dk
Fri May 6 08:09:41 PDT 2022
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
More information about the Linux-nvme
mailing list