* [PATCH] scsi: virtio_scsi: fixup endian conversions for warning messages
@ 2026-06-23 13:24 Ben Dooks
2026-06-24 18:07 ` Stefan Hajnoczi
0 siblings, 1 reply; 2+ messages in thread
From: Ben Dooks @ 2026-06-23 13:24 UTC (permalink / raw)
To: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Stefan Hajnoczi,
Eugenio Pérez, James E.J. Bottomley, Martin K. Petersen,
virtualization, linux-scsi, linux-kernel
Cc: Ben Dooks
There are several places where printing functions are being passed parameters
that have not been through endian conversion functions. Use the virtio32_to_cpu
to fix the warnings.
Fixes the following warnings from (prototype) sparse:
drivers/scsi/virtio_scsi.c:126:9: warning: incorrect type in argument 7 (different base types)
drivers/scsi/virtio_scsi.c:126:9: expected unsigned int
drivers/scsi/virtio_scsi.c:126:9: got restricted __virtio32 [usertype] sense_len
drivers/scsi/virtio_scsi.c:312:17: warning: incorrect type in argument 2 (different base types)
drivers/scsi/virtio_scsi.c:312:17: expected unsigned int
drivers/scsi/virtio_scsi.c:312:17: got restricted __virtio32 [usertype] reason
drivers/scsi/virtio_scsi.c:412:17: warning: incorrect type in argument 2 (different base types)
drivers/scsi/virtio_scsi.c:412:17: expected unsigned int
drivers/scsi/virtio_scsi.c:412:17: got restricted __virtio32 [usertype] event
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
drivers/scsi/virtio_scsi.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 5fdaa71f0652..35731b18c519 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -122,10 +122,11 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
struct virtio_scsi_cmd *cmd = buf;
struct scsi_cmnd *sc = cmd->sc;
struct virtio_scsi_cmd_resp *resp = &cmd->resp.cmd;
+ unsigned sense_len = virtio32_to_cpu(vscsi->vdev, resp->sense_len);
dev_dbg(&sc->device->sdev_gendev,
"cmd %p response %u status %#02x sense_len %u\n",
- sc, resp->response, resp->status, resp->sense_len);
+ sc, resp->response, resp->status, sense_len);
sc->result = resp->status;
virtscsi_compute_resid(sc, virtio32_to_cpu(vscsi->vdev, resp->resid));
@@ -166,13 +167,10 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
break;
}
- WARN_ON(virtio32_to_cpu(vscsi->vdev, resp->sense_len) >
- VIRTIO_SCSI_SENSE_SIZE);
+ WARN_ON(sense_len > VIRTIO_SCSI_SENSE_SIZE);
if (resp->sense_len) {
memcpy(sc->sense_buffer, resp->sense,
- min_t(u32,
- virtio32_to_cpu(vscsi->vdev, resp->sense_len),
- VIRTIO_SCSI_SENSE_SIZE));
+ min_t(u32, sense_len, VIRTIO_SCSI_SENSE_SIZE));
}
scsi_done(sc);
@@ -288,8 +286,9 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
unsigned int target = event->lun[1];
unsigned int lun = (event->lun[2] << 8) | event->lun[3];
+ unsigned int reason = virtio32_to_cpu(vscsi->vdev, event->reason);
- switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
+ switch (reason) {
case VIRTIO_SCSI_EVT_RESET_RESCAN:
if (lun == 0) {
scsi_scan_target(&shost->shost_gendev, 0, target,
@@ -309,7 +308,7 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
}
break;
default:
- pr_info("Unsupported virtio scsi event reason %x\n", event->reason);
+ pr_info("Unsupported virtio scsi event reason %x\n", reason);
}
}
@@ -409,7 +408,8 @@ static void virtscsi_handle_event(struct work_struct *work)
virtscsi_handle_param_change(vscsi, event);
break;
default:
- pr_err("Unsupported virtio scsi event %x\n", event->event);
+ pr_err("Unsupported virtio scsi event %x\n",
+ virtio32_to_cpu(vscsi->vdev, event->event));
}
virtscsi_kick_event(vscsi, event_node);
}
--
2.37.2.352.g3c44437643
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] scsi: virtio_scsi: fixup endian conversions for warning messages
2026-06-23 13:24 [PATCH] scsi: virtio_scsi: fixup endian conversions for warning messages Ben Dooks
@ 2026-06-24 18:07 ` Stefan Hajnoczi
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2026-06-24 18:07 UTC (permalink / raw)
To: Ben Dooks
Cc: Michael S. Tsirkin, Jason Wang, Paolo Bonzini, Eugenio Pérez,
James E.J. Bottomley, Martin K. Petersen, virtualization,
linux-scsi, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1277 bytes --]
On Tue, Jun 23, 2026 at 02:24:27PM +0100, Ben Dooks wrote:
> There are several places where printing functions are being passed parameters
> that have not been through endian conversion functions. Use the virtio32_to_cpu
> to fix the warnings.
>
> Fixes the following warnings from (prototype) sparse:
> drivers/scsi/virtio_scsi.c:126:9: warning: incorrect type in argument 7 (different base types)
> drivers/scsi/virtio_scsi.c:126:9: expected unsigned int
> drivers/scsi/virtio_scsi.c:126:9: got restricted __virtio32 [usertype] sense_len
> drivers/scsi/virtio_scsi.c:312:17: warning: incorrect type in argument 2 (different base types)
> drivers/scsi/virtio_scsi.c:312:17: expected unsigned int
> drivers/scsi/virtio_scsi.c:312:17: got restricted __virtio32 [usertype] reason
> drivers/scsi/virtio_scsi.c:412:17: warning: incorrect type in argument 2 (different base types)
> drivers/scsi/virtio_scsi.c:412:17: expected unsigned int
> drivers/scsi/virtio_scsi.c:412:17: got restricted __virtio32 [usertype] event
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> ---
> drivers/scsi/virtio_scsi.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-24 18:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23 13:24 [PATCH] scsi: virtio_scsi: fixup endian conversions for warning messages Ben Dooks
2026-06-24 18:07 ` Stefan Hajnoczi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox