Skip to contentSkip to conversation

Fix ivshmem build on 32-bit hosts

PATCH Applied Avi Kivity 3 participants 3 messages Aug 29, 2010 – Sep 4, 2010

lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 Fix ivshmem build on 32-bit hosts

stat() fields can be more or less anything depending on configuration, cast explicitly to uint64_t to avoid printf() format mismatches.

---
 hw/ivshmem.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
hw/ivshmem.c +4 -3
index bbb5cba..9a61c69 100644
@@ -351,9 +351,10 @@ static int check_shm_size(IVShmemState *s, int fd) {
     fstat(fd, &buf);
 
     if (s->ivshmem_size > buf.st_size) {
-        fprintf(stderr, "IVSHMEM ERROR: Requested memory size greater");
-        fprintf(stderr, " than shared object size (%" PRIu64 " > %ld)\n",
-                                          s->ivshmem_size, buf.st_size);
+        fprintf(stderr,
+                "IVSHMEM ERROR: Requested memory size greater"
+                " than shared object size (%" PRIu64 " > %" PRIu64")\n",
+                s->ivshmem_size, (uint64_t)buf.st_size);
         return -1;
     } else {
         return 0;
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Avi Kivity

stat() fields can be more or less anything depending on configuration, cast explicitly to uint64_t to avoid printf() format mismatches.

I got a very similar patch in my queue:

fprintf(stderr, " than shared object size (%" PRIu64 " > %ld)\n",
- s->ivshmem_size, buf.st_size);
+ s->ivshmem_size, (ulong)buf.st_size);

But I guess your version is better - it loses less bits :).

Alex

Applied
#2 lore raw
In reply to Avi Kivity

Thanks, applied.

Quoted 31 lines · Avi Kivity

stat() fields can be more or less anything depending on configuration, cast explicitly to uint64_t to avoid printf() format mismatches.

---
 hw/ivshmem.c |    7 ++++---

 1 files changed, 4 insertions(+), 3 deletions(-)
hw/ivshmem.c +4 -4
index bbb5cba..9a61c69 100644
@@ -351,9 +351,10 @@ static int check_shm_size(IVShmemState *s, int fd) {
     fstat(fd, &buf);
 
     if (s->ivshmem_size > buf.st_size) {
-        fprintf(stderr, "IVSHMEM ERROR: Requested memory size greater");
-        fprintf(stderr, " than shared object size (%" PRIu64 " > %ld)\n",
-                                          s->ivshmem_size, buf.st_size);
+        fprintf(stderr,
+                "IVSHMEM ERROR: Requested memory size greater"
+                " than shared object size (%" PRIu64 " > %" PRIu64")\n",
+                s->ivshmem_size, (uint64_t)buf.st_size);
         return -1;
     } else {
         return 0;
--

1.7.1