qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-5.1 4/5] qobject: Eliminate qdict_iter(), use qdict_first


From: Eric Blake
Subject: Re: [PATCH for-5.1 4/5] qobject: Eliminate qdict_iter(), use qdict_first(), qdict_next()
Date: Wed, 15 Apr 2020 07:34:20 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0

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 <address@hidden>
---
  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 <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]