On 4/15/20 3:30 AM, Markus Armbruster wrote:
qdict_iter() has just three uses and no test coverage. Replace by
qdict_first(), qdict_next() for more concise code and less type
punning.
Signed-off-by: Markus Armbruster <arm...@redhat.com>
---
include/qapi/qmp/qdict.h | 3 --
qapi/qobject-input-visitor.c | 21 +++++++-------
qobject/qdict.c | 19 -------------
qobject/qjson.c | 54 +++++++++++++-----------------------
util/qemu-option.c | 10 ++++++-
5 files changed, 40 insertions(+), 67 deletions(-)
static const QListEntry *qobject_input_push(QObjectInputVisitor *qiv,
const char *name,
QObject *obj, void *qapi)
{
GHashTable *h;
StackObject *tos = g_new0(StackObject, 1);
+ QDict *qdict = qobject_to(QDict, obj);
+ QList *qlist = qobject_to(QList, obj);
+ const QDictEntry *entry;
assert(obj);
tos->name = name;
tos->obj = obj;
tos->qapi = qapi;
- if (qobject_type(obj) == QTYPE_QDICT) {
+ if (qdict) {
h = g_hash_table_new(g_str_hash, g_str_equal);
- qdict_iter(qobject_to(QDict, obj), qdict_add_key, h);
+ for (entry = qdict_first(qdict);
+ entry;
+ entry = qdict_next(qdict, entry)) {
+ g_hash_table_insert(h, (void *)qdict_entry_key(entry), NULL);
Is the cast to void* necessary?
Otherwise,
Reviewed-by: Eric Blake <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org