Commit 3abcdf4904d695a9501d7886aa0d243cf086c087

Authored by Stefan Weil
Committed by Anthony Liguori
1 parent ffe6370c

Fix dump output in qemu-io.

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 <weil@mail.berlios.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing 1 changed file with 4 additions and 4 deletions
qemu-io.c
@@ -54,20 +54,20 @@ static void qemu_io_free(void *p) @@ -54,20 +54,20 @@ static void qemu_io_free(void *p)
54 } 54 }
55 55
56 static void 56 static void
57 -dump_buffer(char *buffer, int64_t offset, int len) 57 +dump_buffer(const void *buffer, int64_t offset, int len)
58 { 58 {
59 int i, j; 59 int i, j;
60 - char *p; 60 + const uint8_t *p;
61 61
62 for (i = 0, p = buffer; i < len; i += 16) { 62 for (i = 0, p = buffer; i < len; i += 16) {
63 - char *s = p; 63 + const uint8_t *s = p;
64 64
65 printf("%08llx: ", (unsigned long long)offset + i); 65 printf("%08llx: ", (unsigned long long)offset + i);
66 for (j = 0; j < 16 && i + j < len; j++, p++) 66 for (j = 0; j < 16 && i + j < len; j++, p++)
67 printf("%02x ", *p); 67 printf("%02x ", *p);
68 printf(" "); 68 printf(" ");
69 for (j = 0; j < 16 && i + j < len; j++, s++) { 69 for (j = 0; j < 16 && i + j < len; j++, s++) {
70 - if (isalnum((int)*s)) 70 + if (isalnum(*s))
71 printf("%c", *s); 71 printf("%c", *s);
72 else 72 else
73 printf("."); 73 printf(".");