qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [COMMIT 3abcdf4] Fix dump output in qemu-io.


From: Anthony Liguori
Subject: [Qemu-commits] [COMMIT 3abcdf4] Fix dump output in qemu-io.
Date: Tue, 30 Jun 2009 00:57:24 -0000

From: Stefan Weil <address@hidden>

The dump output was not nicely formatted for bytes
larger than 0x7f, because signed values expanded to
sizeof(int) bytes. So for example 0xab did not print
as "ab", but as "ffffffab".

I also cleaned the function prototype, which avoids
new type casts and allows to remove an existing
type cast.

Signed-off-by: Stefan Weil <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

diff --git a/qemu-io.c b/qemu-io.c
index f0a17b9..e2a3a1b 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -54,20 +54,20 @@ static void qemu_io_free(void *p)
 }
 
 static void
-dump_buffer(char *buffer, int64_t offset, int len)
+dump_buffer(const void *buffer, int64_t offset, int len)
 {
        int i, j;
-       char *p;
+       const uint8_t *p;
 
        for (i = 0, p = buffer; i < len; i += 16) {
-               char    *s = p;
+               const uint8_t *s = p;
 
                printf("%08llx:  ", (unsigned long long)offset + i);
                for (j = 0; j < 16 && i + j < len; j++, p++)
                        printf("%02x ", *p);
                printf(" ");
                for (j = 0; j < 16 && i + j < len; j++, s++) {
-                       if (isalnum((int)*s))
+                       if (isalnum(*s))
                                printf("%c", *s);
                        else
                                printf(".");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]