qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 06/16] check-qjson: Simplify around compare_litqobj_to_qobj()
Date: Wed, 22 Feb 2017 20:14:48 +0100	[thread overview]
Message-ID: <1487790898-24921-7-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com>

Make compare_litqobj_to_qobj() cope with null, and drop non-null
assertions from callers.

compare_litqobj_to_qobj() already checks the QType matches; drop the
redundant assertions from callers.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1487363905-9480-5-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/check-qjson.c | 22 +---------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 0b21a22..49e02591 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -1110,7 +1110,7 @@ static void compare_helper(QObject *obj, void *opaque)
 
 static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs)
 {
-    if (lhs->type != qobject_type(rhs)) {
+    if (!rhs || lhs->type != qobject_type(rhs)) {
         return 0;
     }
 
@@ -1184,18 +1184,12 @@ static void simple_dict(void)
         QString *str;
 
         obj = qobject_from_json(test_cases[i].encoded);
-        g_assert(obj != NULL);
-        g_assert(qobject_type(obj) == QTYPE_QDICT);
-
         g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
 
         str = qobject_to_json(obj);
         qobject_decref(obj);
 
         obj = qobject_from_json(qstring_get_str(str));
-        g_assert(obj != NULL);
-        g_assert(qobject_type(obj) == QTYPE_QDICT);
-
         g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
         qobject_decref(obj);
         QDECREF(str);
@@ -1299,18 +1293,12 @@ static void simple_list(void)
         QString *str;
 
         obj = qobject_from_json(test_cases[i].encoded);
-        g_assert(obj != NULL);
-        g_assert(qobject_type(obj) == QTYPE_QLIST);
-
         g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
 
         str = qobject_to_json(obj);
         qobject_decref(obj);
 
         obj = qobject_from_json(qstring_get_str(str));
-        g_assert(obj != NULL);
-        g_assert(qobject_type(obj) == QTYPE_QLIST);
-
         g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
         qobject_decref(obj);
         QDECREF(str);
@@ -1367,18 +1355,12 @@ static void simple_whitespace(void)
         QString *str;
 
         obj = qobject_from_json(test_cases[i].encoded);
-        g_assert(obj != NULL);
-        g_assert(qobject_type(obj) == QTYPE_QLIST);
-
         g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
 
         str = qobject_to_json(obj);
         qobject_decref(obj);
 
         obj = qobject_from_json(qstring_get_str(str));
-        g_assert(obj != NULL);
-        g_assert(qobject_type(obj) == QTYPE_QLIST);
-
         g_assert(compare_litqobj_to_qobj(&test_cases[i].decoded, obj) == 1);
 
         qobject_decref(obj);
@@ -1403,8 +1385,6 @@ static void simple_varargs(void)
     g_assert(embedded_obj != NULL);
 
     obj = qobject_from_jsonf("[%d, 2, %p]", 1, embedded_obj);
-    g_assert(obj != NULL);
-
     g_assert(compare_litqobj_to_qobj(&decoded, obj) == 1);
 
     qobject_decref(obj);
-- 
2.7.4

  parent reply	other threads:[~2017-02-22 19:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22 19:14 [Qemu-devel] [PULL 00/16] QAPI patches for 2017-02-22 Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 01/16] numa: Flatten simple union NumaOptions Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 02/16] net: Flatten simple union NetLegacyOptions Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 03/16] qdict: Make qdict_get_qlist() safe like qdict_get_qdict() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 04/16] check-qdict: Simplify qdict_crumple_test_recursive() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 05/16] check-qdict: Tighten qdict_crumple_test_recursive() some Markus Armbruster
2017-02-22 19:14 ` Markus Armbruster [this message]
2017-02-22 19:14 ` [Qemu-devel] [PULL 07/16] libqtest: Clean up qmp_response() a bit Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 08/16] test-qmp-event: Simplify and tighten event_test_emit() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 09/16] Don't check qobject_type() before qobject_to_qdict() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 10/16] tests: Don't check qobject_type() before qobject_to_qlist() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 11/16] tests: Don't check qobject_type() before qobject_to_qstring() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 12/16] tests: Don't check qobject_type() before qobject_to_qint() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 13/16] tests: Don't check qobject_type() before qobject_to_qfloat() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 14/16] tests: Don't check qobject_type() before qobject_to_qbool() Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 15/16] monitor: Clean up handle_hmp_command() a bit Markus Armbruster
2017-02-22 19:14 ` [Qemu-devel] [PULL 16/16] block: Don't bother asserting type of output visitor's output Markus Armbruster
2017-02-24 17:27 ` [Qemu-devel] [PULL 00/16] QAPI patches for 2017-02-22 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487790898-24921-7-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).