[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH] scsi-disk: Use (unsigned long) t
From: |
Eric Blake |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH] scsi-disk: Use (unsigned long) typecasts when using "%lu" format string |
Date: |
Mon, 13 Jun 2016 09:27:46 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
On 06/13/2016 02:10 AM, Thomas Huth wrote:
> Some source code analyzers like cppcheck spill out a warning if
> the sign of the argument does not match the format string.
>
> Ticket: https://bugs.launchpad.net/qemu/+bug/1589564
> Signed-off-by: Thomas Huth <address@hidden>
> ---
> hw/scsi/scsi-disk.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index 1881969..36f8a85 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -2060,13 +2060,13 @@ static int32_t scsi_disk_emulate_command(SCSIRequest
> *req, uint8_t *buf)
> }
> break;
> case MODE_SELECT:
> - DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer);
> + DPRINTF("Mode Select(6) (len %lu)\n", (unsigned
> long)r->req.cmd.xfer);
Why do we need a cast in the first place? r->req.cmd.xfer is size_t, so
why not just "Mode Select(6) (len %zu)\n", r->req.cmd.xfer)?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature