qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 08/18] qdict qlist: Make most helper macros func


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 08/18] qdict qlist: Make most helper macros functions
Date: Tue, 30 Jan 2018 11:02:24 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

On 01/30/2018 04:21 AM, Markus Armbruster wrote:
> The macro expansions of qdict_put_TYPE() and qlist_append_TYPE() need
> qbool.h, qnull.h, qnum.h and qstring.h to compile.  We include qnull.h
> and qnum.h in the headers, but not qbool.h and qstring.h.  Works,
> because we include those wherever the macros get used.
> 
> Open-coding these helpers is of dubious value.  Turn them into
> functions and drop the includes from the headers.
> 
> This cleanup makes the number of objects depending on qapi/qmp/qnum.h
> from 4548 (out of 4739) to 46 in my "build everything" tree.  For
> qapi/qmp/qnull.h, the number drops from 4549 to 21.

Impressive!


> +++ b/qobject/qdict.c
> @@ -14,6 +14,7 @@
>  #include "qapi/qmp/qnum.h"
>  #include "qapi/qmp/qdict.h"
>  #include "qapi/qmp/qbool.h"
> +#include "qapi/qmp/qnull.h"
>  #include "qapi/qmp/qstring.h"
>  #include "qapi/qmp/qobject.h"
>  #include "qapi/error.h"
> @@ -143,6 +144,26 @@ void qdict_put_obj(QDict *qdict, const char *key, 
> QObject *value)
>      }
>  }
>  
> +void qdict_put_int(QDict *qdict, const char *key, int64_t value)
> +{
> +    qdict_put(qdict, key, qnum_from_int(value));
> +}

If I'm not mistaken (although I didn't actually test), this triggers a
false positive in scripts/coccinelle/qobject.cocci, no?  Is there a
convenient way to tell coccinelle that a rewrite pattern applies
everywhere except for where the pattern itself is implemented?  But even
if not, we can always use manual inspection when rerunning Coccinelle to
make sure we don't turn these into infinite loops.

Reviewed-by: Eric Blake <address@hidden>

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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