[libvirt] [PATCH libvirt 3/6] Fix warnings about pid_t printf format on mingw64

Eric Blake eblake at redhat.com
Thu Jan 26 00:06:22 UTC 2012


On 01/25/2012 01:13 PM, Marc-André Lureau wrote:
> Define PID_FORMAT and fix warnings for mingw64 x86_64 build.
> 
> Unfortunately, gnu_printf attribute check expect %lld while normal
> printf is PRId64. So one warning remains.
> ---
>  src/rpc/virnetsocket.c |    4 ++--
>  src/util/command.c     |   10 +++++-----
>  src/util/util.h        |    8 ++++++++
>  src/util/virpidfile.c  |    6 +++---
>  4 files changed, 18 insertions(+), 10 deletions(-)

This failed 'make syntax-check':

libvirt_unmarked_diagnostics
src/util/command.c-2198-                             PID_FORMAT ")
status unexpected: %s"),

which may be a flaw in cfg.mk rather than an actual bug, but still one
we should address.

Also, I'm not quite convinced on your approach.  While it's nice to hide
the type behind a macro:
>  
> +#ifdef _WIN64
> +/* XXX gnu_printf prefers lld while non-gnu printf expect PRId64... */

Libvirt should not be using non-gnu printf.  What function call gave you
that warning, so that we can fix it to use gnu printf?

> +# define PID_FORMAT "lld"
> +#else
> +# define PID_FORMAT "d"
> +#endif

the decision should _not_ be based on _WIN64, but instead on a
configure-time test on the underlying type of pid_t.  And since _that_
gets difficult, I'd almost rather go with the simpler approach of:

"%" PRIdMAX, (intmax_t) pid

everywhere that we currently use

"%d", pid

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120125/134b66a5/attachment-0001.sig>


More information about the libvir-list mailing list