[Spice-devel] [spice-gtk 1/2] mingw: Use G_GUINT64_FORMAT with glib printing functions
Christophe Fergeau
cfergeau at redhat.com
Mon Oct 1 15:23:39 UTC 2018
Hey,
On Mon, Oct 01, 2018 at 05:19:42AM -0400, Frediano Ziglio wrote:
> >
> > mingw builds currently trigger a few warnings:
> > ../../src/channel-cursor.c: In function 'set_cursor':
> > ../../src/channel-cursor.c:392:210: warning: 'I' flag used with '%x'
> > gnu_printf format [-Wformat=]
> > CHANNEL_DEBUG(channel, "type %s(%d), %" PRIx64 ", %dx%d",
> > ../../src/channel-cursor.c:392:210: warning: format '%x' expects argument of
> > type 'unsigned int', but argument 7 has type 'uint64_t' {aka 'long long
> > unsigned int'} [-Wformat=]
> >
> > See this glib commit for a related issue
> > https://gitlab.gnome.org/GNOME/glib/commit/3d7cde654c4c6f3bdad32f5521f28f5802a7c377
> >
> > This commit switches to using the format specifiers provided by glib
> > instead which won't have the same issue as PRIx64
> >
> > Signed-off-by: Christophe Fergeau <cfergeau at redhat.com>
>
> I think another way should be define that all printf functions are
> using GNU style, that is __USE_MINGW_ANSI_STDIO (I think we define
> this in Windows vdagent), however as the functions we calls are
> GLib function which use GNU convention always, is IMHO more coherent
> to use GLib constants, as this patch is doing.
Yes, glib provides these constants, are we eventually are calling into
glib to do the printing, so we should use the glib constants, rather
than second guessing the format glib is going to expect.
>
> > ---
> > src/channel-base.c | 8 ++++----
> > src/channel-cursor.c | 2 +-
> > src/channel-display-gst.c | 2 +-
> > src/decode-glz.c | 8 ++++----
> > 4 files changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/src/channel-base.c b/src/channel-base.c
> > index 15f25d27..209328f3 100644
> > --- a/src/channel-base.c
> > +++ b/src/channel-base.c
> > @@ -87,7 +87,7 @@ spice_channel_handle_disconnect(SpiceChannel *channel,
> > SpiceMsgIn *in)
> > {
> > SpiceMsgDisconnect *disconnect = spice_msg_in_parsed(in);
> >
> > - CHANNEL_DEBUG(channel, "%s: ts: %" PRIu64", reason: %u", __FUNCTION__,
> > + CHANNEL_DEBUG(channel, "%s: ts: %" G_GUINT64_FORMAT", reason: %u",
> > __FUNCTION__,
> > disconnect->time_stamp, disconnect->reason);
> > }
> >
> > @@ -127,11 +127,11 @@ void
> > spice_channel_handle_wait_for_channels(SpiceChannel *channel, SpiceMsgIn *i
> > .channel = channel
> > };
> >
> > - CHANNEL_DEBUG(channel, "waiting for serial %" PRIu64 " (%d/%d)",
> > data.wait->message_serial, i + 1, wfc->wait_count);
> > + CHANNEL_DEBUG(channel, "waiting for serial %" G_GUINT64_FORMAT "
> > (%d/%d)", data.wait->message_serial, i + 1, wfc->wait_count);
> > if (g_coroutine_condition_wait(&c->coroutine, wait_for_channel,
> > &data))
> > - CHANNEL_DEBUG(channel, "waiting for serial %" PRIu64 ", done",
> > data.wait->message_serial);
> > + CHANNEL_DEBUG(channel, "waiting for serial %" G_GUINT64_FORMAT
> > ", done", data.wait->message_serial);
> > else
> > - CHANNEL_DEBUG(channel, "waiting for serial %" PRIu64 ",
> > cancelled", data.wait->message_serial);
> > + CHANNEL_DEBUG(channel, "waiting for serial %" G_GUINT64_FORMAT
> > ", cancelled", data.wait->message_serial);
> > }
> > }
> >
> > diff --git a/src/channel-cursor.c b/src/channel-cursor.c
> > index 0e19206a..59af0ad4 100644
> > --- a/src/channel-cursor.c
> > +++ b/src/channel-cursor.c
> > @@ -389,7 +389,7 @@ static display_cursor *set_cursor(SpiceChannel *channel,
> > SpiceCursor *scursor)
> > if (scursor->flags & SPICE_CURSOR_FLAGS_NONE)
> > return NULL;
> >
> > - CHANNEL_DEBUG(channel, "%s: type %s(%d), %" PRIx64 ", %dx%d",
> > __FUNCTION__,
> > + CHANNEL_DEBUG(channel, "%s: type %s(%d), %" G_GUINT64_FORMAT ", %dx%d",
> > __FUNCTION__,
>
> was hex, so "%" G_GUINT64_MODIFIER "x"
Indeed, I've fixed it locally.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20181001/72a7abf3/attachment.sig>
More information about the Spice-devel
mailing list