summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2022-07-16 11:53:44 +0200
committerJens Axboe <axboe@kernel.dk>2022-07-16 14:32:48 +0200
commitf2450f8a2c1ec3e88d6674f747b913aa5f21fa59 (patch)
tree785d4f0a0122b3de0199e15795e4925086fdc01a /drivers/block
parentblktrace: Fix the blk_fill_rwbs() kernel-doc header (diff)
downloadlinux-f2450f8a2c1ec3e88d6674f747b913aa5f21fa59.tar.xz
linux-f2450f8a2c1ec3e88d6674f747b913aa5f21fa59.zip
ublk_drv: fix build warning with -Wmaybe-uninitialized and one sparse warning
After applying -Wmaybe-uninitialized manually, two build warnings are triggered: drivers/block/ublk_drv.c:940:11: warning: ‘io’ may be used uninitialized [-Wmaybe-uninitialized] 940 | io->flags &= ~UBLK_IO_FLAG_ACTIVE; drivers/block/ublk_drv.c: In function ‘ublk_ctrl_uring_cmd’: drivers/block/ublk_drv.c:1531:9: warning: ‘ret’ may be used uninitialized [-Wmaybe-uninitialized] Fix the 1st one by removing 'io->flags &= ~UBLK_IO_FLAG_ACTIVE;' which isn't needed since the function always return successfully after setting this flag. Fix the 2nd one by always initializing 'ret'. Also fix another sparse warning of 'sparse: sparse: incorrect type in return expression' by changing return type of ublk_setup_iod(). Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20220716095344.222674-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/ublk_drv.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index f10c4319dc1f..2c1b01d7f27d 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -407,7 +407,7 @@ static inline unsigned int ublk_req_build_flags(struct request *req)
return flags;
}
-static int ublk_setup_iod(struct ublk_queue *ubq, struct request *req)
+static blk_status_t ublk_setup_iod(struct ublk_queue *ubq, struct request *req)
{
struct ublksrv_io_desc *iod = ublk_get_iod(ubq, req->tag);
struct ublk_io *io = &ubq->ios[req->tag];
@@ -937,7 +937,6 @@ static int ublk_ch_uring_cmd(struct io_uring_cmd *cmd, unsigned int issue_flags)
return -EIOCBQUEUED;
out:
- io->flags &= ~UBLK_IO_FLAG_ACTIVE;
io_uring_cmd_done(cmd, ret, 0);
pr_devel("%s: complete: cmd op %d, tag %d ret %x io_flags %x\n",
__func__, cmd_op, tag, ret, io->flags);
@@ -1299,13 +1298,12 @@ 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 = -EINVAL;
ub = ublk_get_device_from_id(header->dev_id);
if (!ub)
goto out;
- ret = -EINVAL;
queue = header->data[0];
if (queue >= ub->dev_info.nr_hw_queues)
goto out;