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 03/16] qdict: Make qdict_get_qlist() safe like qdict_get_qdict()
Date: Wed, 22 Feb 2017 20:14:45 +0100	[thread overview]
Message-ID: <1487790898-24921-4-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1487790898-24921-1-git-send-email-armbru@redhat.com>

Commit 89cad9f changed qdict_get_qdict() to return NULL instead of
crash when the key doesn't exist or its value isn't a QDict.
Commit 2d6421a neglected to do the same for qdict_get_qlist().
Correct that, and update the function comments.

qdict_get_obj() is now unused, remove.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1487363905-9480-2-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 qobject/qdict.c | 30 +++---------------------------
 1 file changed, 3 insertions(+), 27 deletions(-)

diff --git a/qobject/qdict.c b/qobject/qdict.c
index 197b0fb..b0c5364 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -178,20 +178,6 @@ size_t qdict_size(const QDict *qdict)
 }
 
 /**
- * qdict_get_obj(): Get a QObject of a specific type
- */
-static QObject *qdict_get_obj(const QDict *qdict, const char *key, QType type)
-{
-    QObject *obj;
-
-    obj = qdict_get(qdict, key);
-    assert(obj != NULL);
-    assert(qobject_type(obj) == type);
-
-    return obj;
-}
-
-/**
  * qdict_get_double(): Get an number mapped by 'key'
  *
  * This function assumes that 'key' exists and it stores a
@@ -241,25 +227,15 @@ bool qdict_get_bool(const QDict *qdict, const char *key)
 }
 
 /**
- * qdict_get_qlist(): Get the QList mapped by 'key'
- *
- * This function assumes that 'key' exists and it stores a
- * QList object.
- *
- * Return QList mapped by 'key'.
+ * qdict_get_qlist(): If @qdict maps @key to a QList, return it, else NULL.
  */
 QList *qdict_get_qlist(const QDict *qdict, const char *key)
 {
-    return qobject_to_qlist(qdict_get_obj(qdict, key, QTYPE_QLIST));
+    return qobject_to_qlist(qdict_get(qdict, key));
 }
 
 /**
- * qdict_get_qdict(): Get the QDict mapped by 'key'
- *
- * This function assumes that 'key' exists and it stores a
- * QDict object.
- *
- * Return QDict mapped by 'key'.
+ * qdict_get_qdict(): If @qdict maps @key to a QDict, return it, else NULL.
  */
 QDict *qdict_get_qdict(const QDict *qdict, const char *key)
 {
-- 
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 ` Markus Armbruster [this message]
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 ` [Qemu-devel] [PULL 06/16] check-qjson: Simplify around compare_litqobj_to_qobj() Markus Armbruster
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-4-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).