提交 3abcdf49 编写于 作者: S Stefan Weil 提交者: Anthony Liguori

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: NStefan Weil <weil@mail.berlios.de>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 ffe6370c
......@@ -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(".");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册