qapi/string-output-visitor: fix bugs
in human mode, we are creating the string: 16-31 (16-31) instead of 16-17 (10-1f) because we forgot to pass 'true' as the human parameter on one of the two calls to format_string. Also, this is a worsening of quality; previously we would produce 16 (0x10) to make it obvious which number was hex. Fix these issues. Reported-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
6ffa169576
commit
56fdfb6106
|
@ -98,7 +98,7 @@ static void format_string(StringOutputVisitor *sov, Range *r, bool next,
|
||||||
{
|
{
|
||||||
if (r->end - r->begin > 1) {
|
if (r->end - r->begin > 1) {
|
||||||
if (human) {
|
if (human) {
|
||||||
g_string_append_printf(sov->string, "%" PRIx64 "-%" PRIx64,
|
g_string_append_printf(sov->string, "0x%" PRIx64 "-%" PRIx64,
|
||||||
r->begin, r->end - 1);
|
r->begin, r->end - 1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,7 +107,7 @@ static void format_string(StringOutputVisitor *sov, Range *r, bool next,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (human) {
|
if (human) {
|
||||||
g_string_append_printf(sov->string, "%" PRIx64, r->begin);
|
g_string_append_printf(sov->string, "0x%" PRIx64, r->begin);
|
||||||
} else {
|
} else {
|
||||||
g_string_append_printf(sov->string, "%" PRId64, r->begin);
|
g_string_append_printf(sov->string, "%" PRId64, r->begin);
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ static void print_type_int(Visitor *v, int64_t *obj, const char *name,
|
||||||
g_string_append(sov->string, " (");
|
g_string_append(sov->string, " (");
|
||||||
while (l) {
|
while (l) {
|
||||||
Range *r = l->data;
|
Range *r = l->data;
|
||||||
format_string(sov, r, l->next != NULL, false);
|
format_string(sov, r, l->next != NULL, true);
|
||||||
l = l->next;
|
l = l->next;
|
||||||
}
|
}
|
||||||
g_string_append(sov->string, ")");
|
g_string_append(sov->string, ")");
|
||||||
|
|
Loading…
Reference in New Issue