[spice] server: Use PRI macros in printf for 32/64 bit compatibility

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

 



Some integer type definitions are different between 32 and 64 bit
systems which causes problems in printf. The PRI macros automatically
provide the printf format appropriate for the system.

Signed-off-by: Francois Gouget <fgouget@xxxxxxxxxxxxxxx>
---
 server/char-device.c    | 3 ++-
 server/red-record-qxl.c | 6 +++---
 server/red-replay-qxl.c | 8 ++++----
 server/stream.c         | 4 ++--
 4 files changed, 11 insertions(+), 10 deletions(-)

This is needed on my 32 bit RHEL 6 VM.

diff --git a/server/char-device.c b/server/char-device.c
index 95d31f7..cefc14d 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -21,6 +21,7 @@
 
 
 #include <config.h>
+#include <inttypes.h>
 #include "char-device.h"
 #include "red-channel.h"
 #include "reds.h"
@@ -830,7 +831,7 @@ void spice_char_device_client_remove(SpiceCharDeviceState *dev,
     }
 
     if (dev->num_clients == 0) {
-        spice_debug("client removed, memory pool will be freed (%lu bytes)", dev->cur_pool_size);
+        spice_debug("client removed, memory pool will be freed (%"PRIu64" bytes)", dev->cur_pool_size);
         write_buffers_queue_free(&dev->write_bufs_pool);
         dev->cur_pool_size = 0;
     }
diff --git a/server/red-record-qxl.c b/server/red-record-qxl.c
index 0b966f0..f36d0e4 100644
--- a/server/red-record-qxl.c
+++ b/server/red-record-qxl.c
@@ -255,7 +255,7 @@ static void red_record_image(FILE *fd, RedMemSlotInfo *slots, int group_id,
 
     qxl = (QXLImage *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id,
                                        &error);
-    fprintf(fd, "descriptor.id %ld\n", qxl->descriptor.id);
+    fprintf(fd, "descriptor.id %"PRIu64"\n", qxl->descriptor.id);
     fprintf(fd, "descriptor.type %d\n", qxl->descriptor.type);
     fprintf(fd, "descriptor.flags %d\n", qxl->descriptor.flags);
     fprintf(fd, "descriptor.width %d\n", qxl->descriptor.width);
@@ -280,7 +280,7 @@ static void red_record_image(FILE *fd, RedMemSlotInfo *slots, int group_id,
             memslot_validate_virt(slots, (intptr_t)qp->ents,
                           memslot_get_id(slots, qxl->bitmap.palette),
                           num_ents * sizeof(qp->ents[0]), group_id);
-            fprintf(fd, "unique %ld\n", qp->unique);
+            fprintf(fd, "unique %"PRIu64"\n", qp->unique);
             for (i = 0; i < num_ents; i++) {
                 fprintf(fd, "ents %d\n", qp->ents[i]);
             }
@@ -742,7 +742,7 @@ static void red_record_cursor(FILE *fd, RedMemSlotInfo *slots, int group_id,
     qxl = (QXLCursor *)memslot_get_virt(slots, addr, sizeof(*qxl), group_id,
                                         &error);
 
-    fprintf(fd, "header.unique %ld\n", qxl->header.unique);
+    fprintf(fd, "header.unique %"PRIu64"\n", qxl->header.unique);
     fprintf(fd, "header.type %d\n", qxl->header.type);
     fprintf(fd, "header.width %d\n", qxl->header.width);
     fprintf(fd, "header.height %d\n", qxl->header.height);
diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index ef7477a..cedd126 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -370,7 +370,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
     }
 
     qxl = (QXLImage*)malloc(sizeof(QXLImage));
-    replay_fscanf(replay, "descriptor.id %ld\n", &qxl->descriptor.id);
+    replay_fscanf(replay, "descriptor.id %"PRIu64"\n", &qxl->descriptor.id);
     replay_fscanf(replay, "descriptor.type %d\n", &temp); qxl->descriptor.type = temp;
     replay_fscanf(replay, "descriptor.flags %d\n", &temp); qxl->descriptor.flags = temp;
     replay_fscanf(replay, "descriptor.width %d\n", &qxl->descriptor.width);
@@ -393,7 +393,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags)
             qp = malloc(sizeof(QXLPalette) + num_ents * sizeof(qp->ents[0]));
             qp->num_ents = num_ents;
             qxl->bitmap.palette = (QXLPHYSICAL)qp;
-            replay_fscanf(replay, "unique %ld\n", &qp->unique);
+            replay_fscanf(replay, "unique %"PRIu64"\n", &qp->unique);
             for (i = 0; i < num_ents; i++) {
                 replay_fscanf(replay, "ents %d\n", &qp->ents[i]);
             }
@@ -1121,7 +1121,7 @@ SPICE_GNUC_VISIBLE QXLCommandExt* spice_replay_next_cmd(SpiceReplay *replay,
     int counter;
 
     while (what != 0) {
-        replay_fscanf(replay, "event %d %d %d %ld\n", &counter,
+        replay_fscanf(replay, "event %d %d %d %"PRIu64"\n", &counter,
                             &what, &type, &timestamp);
         if (replay->eof) {
             return NULL;
@@ -1133,7 +1133,7 @@ SPICE_GNUC_VISIBLE QXLCommandExt* spice_replay_next_cmd(SpiceReplay *replay,
     cmd = g_slice_new(QXLCommandExt);
     cmd->cmd.type = type;
     cmd->group_id = 0;
-    spice_debug("command %ld, %d\r", timestamp, cmd->cmd.type);
+    spice_debug("command %"PRIu64", %d\r", timestamp, cmd->cmd.type);
     switch (cmd->cmd.type) {
     case QXL_CMD_DRAW:
         cmd->flags = 0;
diff --git a/server/stream.c b/server/stream.c
index 811f7d3..3120860 100644
--- a/server/stream.c
+++ b/server/stream.c
@@ -38,8 +38,8 @@ void stream_agent_stats_print(StreamAgent *agent)
         mjpeg_encoder_get_stats(agent->mjpeg_encoder, &encoder_stats);
     }
 
-    spice_debug("stream=%p dim=(%dx%d) #in-frames=%lu #in-avg-fps=%.2f #out-frames=%lu "
-                "out/in=%.2f #drops=%lu (#pipe=%lu #fps=%lu) out-avg-fps=%.2f "
+    spice_debug("stream=%p dim=(%dx%d) #in-frames=%"PRIu64" #in-avg-fps=%.2f #out-frames=%"PRIu64" "
+                "out/in=%.2f #drops=%"PRIu64" (#pipe=%"PRIu64" #fps=%"PRIu64") out-avg-fps=%.2f "
                 "passed-mm-time(sec)=%.2f size-total(MB)=%.2f size-per-sec(Mbps)=%.2f "
                 "size-per-frame(KBpf)=%.2f avg-quality=%.2f "
                 "start-bit-rate(Mbps)=%.2f end-bit-rate(Mbps)=%.2f",
-- 
2.6.2

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]