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

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

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':

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 redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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