[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 09/25] vhost-user: Express sizeof with size_t



On Wed, Feb 20, 2019 at 2:05 AM Philippe Mathieu-Daudé
<philmd@xxxxxxxxxx> wrote:
>
> VHOST_USER_HDR_SIZE uses offsetof(), thus is an expression of type
> size_t. Update the format string accordingly.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>

Reviewed-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

> ---
>  hw/virtio/vhost-user.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 564a31d12c..2eb7143d3d 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -215,11 +215,12 @@ static int vhost_user_read(struct vhost_dev *dev, 
> VhostUserMsg *msg)
>      struct vhost_user *u = dev->opaque;
>      CharBackend *chr = u->user->chr;
>      uint8_t *p = (uint8_t *) msg;
> -    int r, size = VHOST_USER_HDR_SIZE;
> +    int r;
> +    size_t size = VHOST_USER_HDR_SIZE;
>
>      r = qemu_chr_fe_read_all(chr, p, size);
>      if (r != size) {
> -        error_report("Failed to read msg header. Read %d instead of %d."
> +        error_report("Failed to read msg header. Read %d instead of %zu."
>                       " Original request %d.", r, size, msg->hdr.request);
>          goto fail;
>      }
> @@ -235,7 +236,7 @@ static int vhost_user_read(struct vhost_dev *dev, 
> VhostUserMsg *msg)
>      /* validate message size is sane */
>      if (msg->hdr.size > VHOST_USER_PAYLOAD_SIZE) {
>          error_report("Failed to read msg header."
> -                " Size %d exceeds the maximum %zu.", msg->hdr.size,
> +                " Size %u exceeds the maximum %zu.", msg->hdr.size,
>                  VHOST_USER_PAYLOAD_SIZE);
>          goto fail;
>      }
> @@ -246,7 +247,7 @@ static int vhost_user_read(struct vhost_dev *dev, 
> VhostUserMsg *msg)
>          r = qemu_chr_fe_read_all(chr, p, size);
>          if (r != size) {
>              error_report("Failed to read msg payload."
> -                         " Read %d instead of %d.", r, msg->hdr.size);
> +                         " Read %d instead of %u.", r, msg->hdr.size);
>              goto fail;
>          }
>      }
> @@ -300,7 +301,8 @@ static int vhost_user_write(struct vhost_dev *dev, 
> VhostUserMsg *msg,
>  {
>      struct vhost_user *u = dev->opaque;
>      CharBackend *chr = u->user->chr;
> -    int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size;
> +    int ret;
> +    size_t size = VHOST_USER_HDR_SIZE + msg->hdr.size;
>
>      /*
>       * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE,
> @@ -320,7 +322,7 @@ static int vhost_user_write(struct vhost_dev *dev, 
> VhostUserMsg *msg,
>      ret = qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size);
>      if (ret != size) {
>          error_report("Failed to write msg."
> -                     " Wrote %d instead of %d.", ret, size);
> +                     " Wrote %d instead of %zu.", ret, size);
>          return -1;
>      }
>
> --
> 2.20.1
>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.