qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: mdroth@linux.vnet.ibm.com
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	[thread overview]
Message-ID: <4574d8dc-0892-ff10-1823-697bff10f0b0@redhat.com> (raw)
In-Reply-To: <20200415083048.14339-5-armbru@redhat.com>

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 <armbru@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 <eblake@redhat.com>

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



  reply	other threads:[~2020-04-15 12:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  8:30 [PATCH for-5.1 0/5] qobject: Minor spring cleaning Markus Armbruster
2020-04-15  8:30 ` [PATCH for-5.1 1/5] qobject: Clean up QLIST_FOREACH_ENTRY() Markus Armbruster
2020-04-15 12:25   ` Eric Blake
2020-04-15  8:30 ` [PATCH for-5.1 2/5] qobject: Factor out helper json_pretty_newline() Markus Armbruster
2020-04-15 12:28   ` Eric Blake
2020-04-15 14:46     ` Markus Armbruster
2020-04-15  8:30 ` [PATCH for-5.1 3/5] qobject: Eliminate qlist_iter(), use QLIST_FOREACH_ENTRY() instead Markus Armbruster
2020-04-15 12:31   ` Eric Blake
2020-04-15  8:30 ` [PATCH for-5.1 4/5] qobject: Eliminate qdict_iter(), use qdict_first(), qdict_next() Markus Armbruster
2020-04-15 12:34   ` Eric Blake [this message]
2020-04-15 14:48     ` Markus Armbruster
2020-04-15  8:30 ` [PATCH for-5.1 5/5] qemu-option: Clean up after the previous commit Markus Armbruster
2020-04-15 12:35   ` Eric Blake
2020-04-29  7:46 ` [PATCH for-5.1 0/5] qobject: Minor spring cleaning Markus Armbruster

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=4574d8dc-0892-ff10-1823-697bff10f0b0@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.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).