* [Qemu-devel] [PATCH] qapi/string-putput-visitor: fix bugs
@ 2014-06-18 15:37 Michael S. Tsirkin
2014-06-18 15:46 ` Eric Blake
0 siblings, 1 reply; 2+ messages in thread
From: Michael S. Tsirkin @ 2014-06-18 15:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Michael Roth, Luiz Capitulino
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>
---
qapi/string-output-visitor.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 8735b00..e9aca3b 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -98,7 +98,7 @@ static void format_string(StringOutputVisitor *sov, Range *r, bool next,
{
if (r->end - r->begin > 1) {
if (human) {
- g_string_append_printf(sov->string, "%" PRIx64 "-%" PRIx64,
+ g_string_append_printf(sov->string, "0x%" PRIx64 "-%" PRIx64,
r->begin, r->end - 1);
} else {
@@ -107,7 +107,7 @@ static void format_string(StringOutputVisitor *sov, Range *r, bool next,
}
} else {
if (human) {
- g_string_append_printf(sov->string, "%" PRIx64, r->begin);
+ g_string_append_printf(sov->string, "0x%" PRIx64, r->begin);
} else {
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, " (");
while (l) {
Range *r = l->data;
- format_string(sov, r, l->next != NULL, false);
+ format_string(sov, r, l->next != NULL, true);
l = l->next;
}
g_string_append(sov->string, ")");
--
MST
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] qapi/string-putput-visitor: fix bugs
2014-06-18 15:37 [Qemu-devel] [PATCH] qapi/string-putput-visitor: fix bugs Michael S. Tsirkin
@ 2014-06-18 15:46 ` Eric Blake
0 siblings, 0 replies; 2+ messages in thread
From: Eric Blake @ 2014-06-18 15:46 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel; +Cc: Michael Roth, Luiz Capitulino
[-- Attachment #1: Type: text/plain, Size: 1559 bytes --]
On 06/18/2014 09:37 AM, Michael S. Tsirkin wrote:
> 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>
> ---
> qapi/string-output-visitor.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
> index 8735b00..e9aca3b 100644
> --- a/qapi/string-output-visitor.c
> +++ b/qapi/string-output-visitor.c
> @@ -98,7 +98,7 @@ static void format_string(StringOutputVisitor *sov, Range *r, bool next,
> {
> if (r->end - r->begin > 1) {
> if (human) {
> - g_string_append_printf(sov->string, "%" PRIx64 "-%" PRIx64,
> + g_string_append_printf(sov->string, "0x%" PRIx64 "-%" PRIx64,
The pre-series code used "%#"PRIx64 instead of "0x%"PRIx64; the only
difference is that you now output 0x0 instead of 0 if that happens to be
one of the values of the range. I personally think "0 (0x0)" is nicer
than the shorter "0 (0)", so I'm okay with it.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-18 15:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 15:37 [Qemu-devel] [PATCH] qapi/string-putput-visitor: fix bugs Michael S. Tsirkin
2014-06-18 15:46 ` Eric Blake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).