Skip to content

Commit f083937

Browse files
committed
virtio_blk: correct types for status handling
virtblk_setup_cmd returns blk_status_t in an int, callers then assign it back to a blk_status_t variable. blk_status_t is either u32 or (more typically) u8 so it works, but is inelegant and causes sparse warnings. Pass the status in blk_status_t in a consistent way. Reported-by: kernel test robot <[email protected]> Fixes: b2c5221 ("virtio-blk: avoid preallocating big SGL for data") Cc: Max Gurtovoy <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent ead65f7 commit f083937

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/block/virtio_blk.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ static void virtblk_cleanup_cmd(struct request *req)
208208
kfree(bvec_virt(&req->special_vec));
209209
}
210210

211-
static int virtblk_setup_cmd(struct virtio_device *vdev, struct request *req,
212-
struct virtblk_req *vbr)
211+
static blk_status_t virtblk_setup_cmd(struct virtio_device *vdev,
212+
struct request *req,
213+
struct virtblk_req *vbr)
213214
{
214215
bool unmap = false;
215216
u32 type;
@@ -317,14 +318,15 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
317318
unsigned long flags;
318319
unsigned int num;
319320
int qid = hctx->queue_num;
320-
int err;
321321
bool notify = false;
322+
blk_status_t status;
323+
int err;
322324

323325
BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
324326

325-
err = virtblk_setup_cmd(vblk->vdev, req, vbr);
326-
if (unlikely(err))
327-
return err;
327+
status = virtblk_setup_cmd(vblk->vdev, req, vbr);
328+
if (unlikely(status))
329+
return status;
328330

329331
blk_mq_start_request(req);
330332

0 commit comments

Comments
 (0)