mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ublk_drv: initialize ret variable
@ 2022-07-16 13:15 Tom Rix
  2022-07-16 13:22 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2022-07-16 13:15 UTC (permalink / raw)
  To: axboe, nathan, ndesaulniers, ming.lei
  Cc: linux-block, linux-kernel, llvm, Tom Rix

clang build fails with
drivers/block/ublk_drv.c:1304:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

When the call to ublk_get_device_from_id() fails, ret is used without being
initized.  So initialize.

Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/block/ublk_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 52fd0af8a4f2..4d1199c98026 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1298,7 +1298,7 @@ static int ublk_ctrl_get_queue_affinity(struct io_uring_cmd *cmd)
 	struct ublk_device *ub;
 	unsigned long queue;
 	unsigned int retlen;
-	int ret;
+	int ret = -ENODEV;
 
 	ub = ublk_get_device_from_id(header->dev_id);
 	if (!ub)
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ublk_drv: initialize ret variable
  2022-07-16 13:15 [PATCH] ublk_drv: initialize ret variable Tom Rix
@ 2022-07-16 13:22 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2022-07-16 13:22 UTC (permalink / raw)
  To: Tom Rix, nathan, ndesaulniers, ming.lei; +Cc: linux-block, linux-kernel, llvm

On 7/16/22 7:15 AM, Tom Rix wrote:
> clang build fails with
> drivers/block/ublk_drv.c:1304:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
> 
> When the call to ublk_get_device_from_id() fails, ret is used without being
> initized.  So initialize.

Should already be fixed:

https://git.kernel.dk/cgit/linux-block/commit/?h=for-5.20/block&id=f2450f8a2c1ec3e88d6674f747b913aa5f21fa59

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-16 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-16 13:15 [PATCH] ublk_drv: initialize ret variable Tom Rix
2022-07-16 13:22 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®