From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8UbY-0004rb-89 for qemu-devel@nongnu.org; Thu, 02 Jun 2016 11:32:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8UbT-0003cm-7E for qemu-devel@nongnu.org; Thu, 02 Jun 2016 11:32:15 -0400 From: Markus Armbruster References: <1463632874-28559-1-git-send-email-eblake@redhat.com> <1463632874-28559-23-git-send-email-eblake@redhat.com> Date: Thu, 02 Jun 2016 17:32:03 +0200 In-Reply-To: <1463632874-28559-23-git-send-email-eblake@redhat.com> (Eric Blake's message of "Wed, 18 May 2016 22:41:08 -0600") Message-ID: <87twhbd2to.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v4 22/28] qobject: Consolidate qobject_to_json() calls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Kevin Wolf , "open list:Block layer core" , Michael Roth , Luiz Capitulino , Max Reitz Eric Blake writes: > It's simpler to have a single conversion function that takes a > bool parameter, rather than two functions where the choice of > function determines an internal bool. Similar to commit fc471c18. > > While at it, the conversion currently cannot fail (maybe it SHOULD > be possible to choose to fail, when encountering invalid UTF-8 > encoding or an Infinity or NaN valued double, but that's a story > for another day), so clean up callers to avoid a needless assert. > And use bool rather than int for 'pretty'. > > Signed-off-by: Eric Blake [...] > diff --git a/tests/check-qobject-json.c b/tests/check-qobject-json.c > index d889501..9814282 100644 > --- a/tests/check-qobject-json.c > +++ b/tests/check-qobject-json.c > @@ -64,7 +64,7 @@ static void escaped_string(void) > g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].decoded); > > if (test_cases[i].skip == 0) { > - str = qobject_to_json(obj); > + str = qobject_to_json(obj, false); > g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].encoded); > qobject_decref(obj); > } > @@ -98,7 +98,7 @@ static void simple_string(void) > str = qobject_to_qstring(obj); > g_assert(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); > > - str = qobject_to_json(obj); > + str = qobject_to_json(obj, false); > g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); > > qobject_decref(obj); > @@ -832,13 +832,8 @@ static void utf8_string(void) > qobject_decref(obj); > > obj = QOBJECT(qstring_from_str(utf8_in)); > - str = qobject_to_json(obj); > - if (json_out) { > - g_assert(str); > - g_assert_cmpstr(qstring_get_str(str), ==, json_out); > - } else { Unreachable, because json_out can be null only when test_cases[o].json_in is, and null json_in would've crashed in qobject_from_json(). > - g_assert(!str); > - } > + str = qobject_to_json(obj, false); > + g_assert_cmpstr(qstring_get_str(str), ==, json_out); > QDECREF(str); > qobject_decref(obj); > Thanks for cleaning up my mess. [...]