From: Eric Blake <eblake@redhat.com>
To: Rami Rosen <rami.rosen@intel.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] ui: fix format specifier in vnc_client_io_error() to avoid break in build.
Date: Mon, 9 Jan 2017 15:35:36 -0600 [thread overview]
Message-ID: <4ae785a3-1cac-99a9-a96d-a866ab9318db@redhat.com> (raw)
In-Reply-To: <1483900123-7103-1-git-send-email-rami.rosen@intel.com>
[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]
On 01/08/2017 12:28 PM, Rami Rosen wrote:
> When building qemu after setting _VNC_DEBUG to 1 (see ui/vnc.h),
> we get the following error and the build breaks:
> ...
> ui/vnc.c: In function ‘vnc_client_io_error’:
> ui/vnc.c:1262:13: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘ssize_t’ [-Werror=format=]
> VNC_DEBUG("Closing down client sock: ret %d (%s)\n",
> ^
> cc1: all warnings being treated as errors
> make: *** [ui/vnc.o] Error 1
> ...
>
> This patch solves this issue by fixing the print format specifier
> in vnc_client_io_error() to be %ld, which corresponds to the type
> of the "ret" variable.
NACK. "ret" is ssize_t, which might be 'long' on some platforms, but is
'int' on others (32-bit platforms come to mind).
>
> Signed-off-by: Rami Rosen <rami.rosen@intel.com>
> ---
> ui/vnc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 2c28a59..4b0a89c 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -1259,7 +1259,7 @@ ssize_t vnc_client_io_error(VncState *vs, ssize_t ret, Error **errp)
> if (ret == 0) {
> VNC_DEBUG("Closing down client sock: EOF\n");
> } else if (ret != QIO_CHANNEL_ERR_BLOCK) {
> - VNC_DEBUG("Closing down client sock: ret %d (%s)\n",
> + VNC_DEBUG("Closing down client sock: ret %ld (%s)\n",
%zd is better than %ld. Note that %zd is technically undefined -
neither C nor POSIX requires that the signed counterpart to 'size_t' be
ssize_t, nor that 'ssize_t' be the same size as 'size_t'; but it is safe
enough in qemu as we already have plenty of existing uses of this idiom
(and any platform that implements 'ssize_t' in a way that doesn't match
'%zd' is stupid when it comes to quality-of-implementation).
Looking forward to v2.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
prev parent reply other threads:[~2017-01-09 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-08 18:28 [Qemu-devel] [PATCH] ui: fix format specifier in vnc_client_io_error() to avoid break in build Rami Rosen
2017-01-09 21:35 ` Eric Blake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ae785a3-1cac-99a9-a96d-a866ab9318db@redhat.com \
--to=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rami.rosen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).