mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-16 03:48:30 +00:00
Remove compile warnings on Linux 32bit system
Based on a patch from Hongzhi.Song <hongzhi.song@windriver.com>. There are following compile errors on Linux 32bit system with -Werror for gcc. red-channel.c:207:73: error: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'long unsigned int' [-Werror=format=] |207| red_channel_debug(self, "thread_id 0x%" G_GSIZE_MODIFIER "x", ~~~~~~~~~~~~~~~~~~~~~^ self->priv->thread_id); ~~~~~~~~~~~~~~~~~~~~~^ pthread_t is an opaque type so there is no easy way to make the printf format string portable. However the type must be comparable in C so this (excluding floating point which does not make sense) means an integral type or a pointer. Under *BSD this is a pointer so can be converted without loosing precision to void*. Under Linux this is a "unsigned long int" type, being Linux ILP32 or LP64 this means that the size of pthread_t is the same as size_t so can be converted without loosing precision to void*. Under MingW (the pthread port to Windows) this is a uintptr_t type that is can be converted without loosing precision to void*. On any potential future platforms if the integral type is smaller than a uintptr_t type (which has the same size of void*) the cast should trigger a warning and if not won't loose precision; the integral type is unlikely to be bigger than a pointer and likely the cast would trigger a warning. The cast on read_binary (red-replay-qxl.c) is safe, "*size" is a size_t while "strm.total_out" is the number of written bytes in a buffer which cannot be bigger than a size_t. Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Uri Lublin <uril@redhat.com>
This commit is contained in:
parent
177a7d3833
commit
0002d1a93c
@ -202,7 +202,7 @@ red_channel_constructed(GObject *object)
|
||||
{
|
||||
RedChannel *self = RED_CHANNEL(object);
|
||||
|
||||
red_channel_debug(self, "thread_id 0x%" G_GSIZE_MODIFIER "x", self->priv->thread_id);
|
||||
red_channel_debug(self, "thread_id %p", (void*) self->priv->thread_id);
|
||||
|
||||
RedChannelClass *klass = RED_CHANNEL_GET_CLASS(self);
|
||||
|
||||
@ -473,11 +473,11 @@ void red_channel_remove_client(RedChannel *channel, RedChannelClient *rcc)
|
||||
|
||||
if (!pthread_equal(pthread_self(), channel->priv->thread_id)) {
|
||||
red_channel_warning(channel,
|
||||
"channel->thread_id (0x%" G_GSIZE_MODIFIER "x) != "
|
||||
"pthread_self (0x%" G_GSIZE_MODIFIER "x)."
|
||||
"channel->thread_id (%p) != "
|
||||
"pthread_self (%p)."
|
||||
"If one of the threads is != io-thread && != vcpu-thread, "
|
||||
"this might be a BUG",
|
||||
channel->priv->thread_id, pthread_self());
|
||||
(void*) channel->priv->thread_id, (void*) pthread_self());
|
||||
}
|
||||
spice_return_if_fail(channel);
|
||||
link = g_list_find(channel->priv->clients, rcc);
|
||||
|
||||
@ -174,11 +174,11 @@ void red_client_migrate(RedClient *client)
|
||||
RedChannel *channel;
|
||||
|
||||
if (!pthread_equal(pthread_self(), client->thread_id)) {
|
||||
spice_warning("client->thread_id (0x%" G_GSIZE_MODIFIER "x) != "
|
||||
"pthread_self (0x%" G_GSIZE_MODIFIER "x)."
|
||||
spice_warning("client->thread_id (%p) != "
|
||||
"pthread_self (%p)."
|
||||
"If one of the threads is != io-thread && != vcpu-thread,"
|
||||
" this might be a BUG",
|
||||
client->thread_id, pthread_self());
|
||||
(void*) client->thread_id, (void*) pthread_self());
|
||||
}
|
||||
FOREACH_CHANNEL_CLIENT(client, rcc) {
|
||||
if (red_channel_client_is_connected(rcc)) {
|
||||
@ -193,12 +193,12 @@ void red_client_destroy(RedClient *client)
|
||||
RedChannelClient *rcc;
|
||||
|
||||
if (!pthread_equal(pthread_self(), client->thread_id)) {
|
||||
spice_warning("client->thread_id (0x%" G_GSIZE_MODIFIER "x) != "
|
||||
"pthread_self (0x%" G_GSIZE_MODIFIER "x)."
|
||||
spice_warning("client->thread_id (%p) != "
|
||||
"pthread_self (%p)."
|
||||
"If one of the threads is != io-thread && != vcpu-thread,"
|
||||
" this might be a BUG",
|
||||
client->thread_id,
|
||||
pthread_self());
|
||||
(void*) client->thread_id,
|
||||
(void*) pthread_self());
|
||||
}
|
||||
red_client_set_disconnecting(client);
|
||||
FOREACH_CHANNEL_CLIENT(client, rcc) {
|
||||
|
||||
@ -265,7 +265,7 @@ static replay_t read_binary(SpiceReplay *replay, const char *prefix, size_t *siz
|
||||
}
|
||||
if ((ret = inflate(&strm, Z_NO_FLUSH)) != Z_STREAM_END) {
|
||||
spice_error("inflate error %d (disc: %" G_GSSIZE_FORMAT ")",
|
||||
ret, *size - strm.total_out);
|
||||
ret, (size_t) (*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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user