From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42655) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHv4-0004kP-4s for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:37:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxHuw-0004CS-MA for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:37:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8355) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxHuw-0004CL-Df for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:36:54 -0400 Date: Wed, 18 Jun 2014 18:37:18 +0300 From: "Michael S. Tsirkin" Message-ID: <1403105835-25535-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] qapi/string-putput-visitor: fix bugs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 Signed-off-by: Michael S. Tsirkin --- 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