From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 01/14] qdict: Make qdict_get_qlist() safe like qdict_get_qdict()
Date: Fri, 17 Feb 2017 21:38:12 +0100 [thread overview]
Message-ID: <1487363905-9480-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1487363905-9480-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>
---
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
next prev parent reply other threads:[~2017-02-17 20:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-17 20:38 [Qemu-devel] [PATCH 00/14] qobject: Cleanups, mostly in tests Markus Armbruster
2017-02-17 20:38 ` Markus Armbruster [this message]
2017-02-17 22:29 ` [Qemu-devel] [PATCH 01/14] qdict: Make qdict_get_qlist() safe like qdict_get_qdict() Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 02/14] check-qdict: Simplify qdict_crumple_test_recursive() Markus Armbruster
2017-02-17 22:34 ` Eric Blake
2017-02-18 10:49 ` Markus Armbruster
2017-02-17 20:38 ` [Qemu-devel] [PATCH 03/14] check-qdict: Tighten qdict_crumple_test_recursive() some Markus Armbruster
2017-02-18 13:11 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 04/14] check-qjson: Simplify around compare_litqobj_to_qobj() Markus Armbruster
2017-02-18 15:54 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 05/14] libqtest: Clean up qmp_response() a bit Markus Armbruster
2017-02-21 2:48 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 06/14] test-qmp-event: Simplify and tighten event_test_emit() Markus Armbruster
2017-02-21 15:03 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 07/14] Don't check qobject_type() before qobject_to_qdict() Markus Armbruster
2017-02-21 15:05 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 08/14] tests: Don't check qobject_type() before qobject_to_qlist() Markus Armbruster
2017-02-21 16:35 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 09/14] tests: Don't check qobject_type() before qobject_to_qstring() Markus Armbruster
2017-02-21 17:50 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 10/14] tests: Don't check qobject_type() before qobject_to_qint() Markus Armbruster
2017-02-21 19:18 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 11/14] tests: Don't check qobject_type() before qobject_to_qfloat() Markus Armbruster
2017-02-21 19:38 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 12/14] tests: Don't check qobject_type() before qobject_to_qbool() Markus Armbruster
2017-02-21 19:44 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 13/14] monitor: Clean up handle_hmp_command() a bit Markus Armbruster
2017-02-21 19:45 ` Eric Blake
2017-02-17 20:38 ` [Qemu-devel] [PATCH 14/14] block: Don't bother asserting type of output visitor's output Markus Armbruster
2017-02-21 19:46 ` Eric Blake
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=1487363905-9480-2-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).