From f831984888aade15c11e8bcbbc3d55bb7a7e30b9 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Tue, 15 Dec 2015 17:49:59 +0000 Subject: [PATCH] server: Use '%zu' to print size_t variables The size_t definition is different between 32 and 64 bit systems so that neither '%u' nor '%lu' work for both. '%zu' should be used instead. Signed-off-by: Francois Gouget Acked-by: Jonathon Jongsma --- server/red_record_qxl.c | 4 ++-- server/red_replay_qxl.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server/red_record_qxl.c b/server/red_record_qxl.c index 4d508d64..0b6f289a 100644 --- a/server/red_record_qxl.c +++ b/server/red_record_qxl.c @@ -114,7 +114,7 @@ static void write_binary(FILE *fd, const char *prefix, size_t size, const uint8_ } #endif - fprintf(fd, "binary %d %s %ld:", WITH_ZLIB, prefix, size); + fprintf(fd, "binary %d %s %zu:", WITH_ZLIB, prefix, size); #if WITH_ZLIB zlib_size = zlib_encode(enc, RECORD_ZLIB_DEFAULT_COMPRESSION_LEVEL, size, output, sizeof(output)); @@ -144,7 +144,7 @@ static size_t red_record_data_chunks_ptr(FILE *fd, const char *prefix, data_size += cur->data_size; count_chunks++; } - fprintf(fd, "data_chunks %d %ld\n", count_chunks, data_size); + fprintf(fd, "data_chunks %d %zu\n", count_chunks, data_size); validate_virt(slots, (intptr_t)qxl->data, memslot_id, qxl->data_size, group_id); write_binary(fd, prefix, qxl->data_size, qxl->data); diff --git a/server/red_replay_qxl.c b/server/red_replay_qxl.c index df1fed6d..ac1ca055 100644 --- a/server/red_replay_qxl.c +++ b/server/red_replay_qxl.c @@ -198,7 +198,7 @@ static replay_t read_binary(SpiceReplay *replay, const char *prefix, size_t *siz if (*buf == NULL) { *buf = malloc(*size + base_size); if (*buf == NULL) { - spice_error("allocation error for %ld", *size); + spice_error("allocation error for %zu", *size); exit(1); } } @@ -259,7 +259,7 @@ static size_t red_replay_data_chunks(SpiceReplay *replay, const char *prefix, size_t next_data_size; QXLDataChunk *cur; - replay_fscanf(replay, "data_chunks %d %ld\n", &count_chunks, &data_size); + replay_fscanf(replay, "data_chunks %d %zu\n", &count_chunks, &data_size); if (base_size == 0) { base_size = sizeof(QXLDataChunk); } @@ -407,7 +407,7 @@ static QXLImage *red_replay_image(SpiceReplay *replay, uint32_t flags) } else { size = red_replay_data_chunks(replay, "bitmap.data", (uint8_t**)&qxl->bitmap.data, 0); if (size != bitmap_size) { - spice_printerr("bad image, %ld != %ld", size, bitmap_size); + spice_printerr("bad image, %zu != %zu", size, bitmap_size); return NULL; } } @@ -1028,7 +1028,7 @@ static QXLSurfaceCmd *red_replay_surface_cmd(SpiceReplay *replay) if ((qxl->flags & QXL_SURF_FLAG_KEEP_DATA) != 0) { read_binary(replay, "data", &read_size, (uint8_t**)&qxl->u.surface_create.data, 0); if (read_size != size) { - spice_printerr("mismatch %ld != %ld", size, read_size); + spice_printerr("mismatch %zu != %zu", size, read_size); } } else { qxl->u.surface_create.data = (QXLPHYSICAL)malloc(size);