[Spice-devel] [PATCH spice-server 01/33] Use PRIxPTR constant for string formatting
Marc-André Lureau
marcandre.lureau at gmail.com
Sat Dec 22 10:10:30 UTC 2018
On Fri, Dec 21, 2018 at 4:03 PM Frediano Ziglio <fziglio at redhat.com> wrote:
>
> These constants are meant to be used in format string for size_t
> types. Use them for portability.
PRI*PTR is for [u]intptr_t.
There are some claims that z is supported since VC2015 on stackoverflow.
I assume we are mainly interested in mingw, we should set
__USE_MINGW_ANSI_STDIO=1 instead.
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/gstreamer-encoder.c | 2 +-
> server/red-channel.c | 5 +++--
> server/red-client.c | 4 ++--
> server/red-replay-qxl.c | 4 ++--
> server/reds.c | 4 ++--
> 5 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
> index 04f0c02f..f81fa223 100644
> --- a/server/gstreamer-encoder.c
> +++ b/server/gstreamer-encoder.c
> @@ -1080,7 +1080,7 @@ static void set_gstenc_bitrate(SpiceGstEncoder *encoder)
> break;
> }
> default:
> - spice_warning("the %s property has an unsupported type %zu",
> + spice_warning("the %s property has an unsupported type %" PRIuPTR,
> prop, param->value_type);
> }
> spice_debug("setting the GStreamer %s to %"PRIu64, prop, gst_bit_rate);
> diff --git a/server/red-channel.c b/server/red-channel.c
> index 448b690e..b94d26b7 100644
> --- a/server/red-channel.c
> +++ b/server/red-channel.c
> @@ -190,7 +190,7 @@ red_channel_constructed(GObject *object)
> {
> RedChannel *self = RED_CHANNEL(object);
>
> - red_channel_debug(self, "thread_id 0x%lx", self->priv->thread_id);
> + red_channel_debug(self, "thread_id 0x%" PRIxPTR, self->priv->thread_id);
>
> RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self);
>
> @@ -468,7 +468,8 @@ void red_channel_remove_client(RedChannel *channel, RedChannelClient *rcc)
> g_return_if_fail(channel == red_channel_client_get_channel(rcc));
>
> if (!pthread_equal(pthread_self(), channel->priv->thread_id)) {
> - red_channel_warning(channel, "channel->thread_id (0x%lx) != pthread_self (0x%lx)."
> + red_channel_warning(channel,
> + "channel->thread_id (0x%" PRIxPTR ") != pthread_self (0x%" PRIxPTR ")."
> "If one of the threads is != io-thread && != vcpu-thread, "
> "this might be a BUG",
> channel->priv->thread_id, pthread_self());
> diff --git a/server/red-client.c b/server/red-client.c
> index 7d14bd19..66bda8da 100644
> --- a/server/red-client.c
> +++ b/server/red-client.c
> @@ -176,7 +176,7 @@ void red_client_migrate(RedClient *client)
> RedChannel *channel;
>
> if (!pthread_equal(pthread_self(), client->thread_id)) {
> - spice_warning("client->thread_id (0x%lx) != pthread_self (0x%lx)."
> + spice_warning("client->thread_id (0x%" PRIxPTR ") != pthread_self (0x%" PRIxPTR ")."
> "If one of the threads is != io-thread && != vcpu-thread,"
> " this might be a BUG",
> client->thread_id, pthread_self());
> @@ -194,7 +194,7 @@ void red_client_destroy(RedClient *client)
> RedChannelClient *rcc;
>
> if (!pthread_equal(pthread_self(), client->thread_id)) {
> - spice_warning("client->thread_id (0x%lx) != pthread_self (0x%lx)."
> + spice_warning("client->thread_id (0x%" PRIxPTR ") != pthread_self (0x%" PRIxPTR ")."
> "If one of the threads is != io-thread && != vcpu-thread,"
> " this might be a BUG",
> client->thread_id,
> diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
> index 6958a495..b3c61769 100644
> --- a/server/red-replay-qxl.c
> +++ b/server/red-replay-qxl.c
> @@ -227,7 +227,7 @@ static replay_t read_binary(SpiceReplay *replay, const char *prefix, size_t *siz
> uint8_t *zlib_buffer;
> z_stream strm;
>
> - snprintf(template, sizeof(template), "binary %%d %s %%ld:%%n", prefix);
> + snprintf(template, sizeof(template), "binary %%d %s %%" PRIdPTR ":%%n", prefix);
> replay_fscanf_check(replay, template, &with_zlib, size, &replay->end_pos);
> if (replay->error) {
> return REPLAY_ERROR;
> @@ -266,7 +266,7 @@ static replay_t read_binary(SpiceReplay *replay, const char *prefix, size_t *siz
> exit(1);
> }
> if ((ret = inflate(&strm, Z_NO_FLUSH)) != Z_STREAM_END) {
> - spice_error("inflate error %d (disc: %ld)", ret, *size - strm.total_out);
> + spice_error("inflate error %d (disc: %" PRIdPTR ")", ret, *size - strm.total_out);
> if (ret == Z_DATA_ERROR) {
> /* last operation may be wrong. since we do the recording
> * in red_worker, when there is a shutdown from the vcpu/io thread
> diff --git a/server/reds.c b/server/reds.c
> index cdbb94cb..98a3435d 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -1149,7 +1149,7 @@ static void reds_on_main_agent_monitors_config(RedsState *reds,
> }
> spice_buffer_append(cmc, message, size);
> if (sizeof(VDAgentMessage) > cmc->offset) {
> - spice_debug("not enough data yet. %zd", cmc->offset);
> + spice_debug("not enough data yet. %" PRIdPTR, cmc->offset);
> return;
> }
> msg_header = (VDAgentMessage *)cmc->buffer;
> @@ -1157,7 +1157,7 @@ static void reds_on_main_agent_monitors_config(RedsState *reds,
> goto overflow;
> }
> if (msg_header->size > cmc->offset - sizeof(VDAgentMessage)) {
> - spice_debug("not enough data yet. %zd", cmc->offset);
> + spice_debug("not enough data yet. %" PRIdPTR, cmc->offset);
> return;
> }
> if (msg_header->size < sizeof(VDAgentMonitorsConfig)) {
> --
> 2.17.2
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
--
Marc-André Lureau
More information about the Spice-devel
mailing list