[Qemu-devel] [PATCH v2 02/54] qdict: add qdict_put_null() helper

Marc-André Lureau posted 54 patches 8 years, 5 months ago
There is a newer version of this series
[Qemu-devel] [PATCH v2 02/54] qdict: add qdict_put_null() helper
Posted by Marc-André Lureau 8 years, 5 months ago
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qapi/qmp/qdict.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index 363e431106..a35bed9f16 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -60,6 +60,8 @@ void qdict_destroy_obj(QObject *obj);
         qdict_put(qdict, key, qbool_from_bool(value))
 #define qdict_put_str(qdict, key, value) \
         qdict_put(qdict, key, qstring_from_str(value))
+#define qdict_put_null(qdict, key) \
+        qdict_put(qdict, key, qnull())
 
 /* High level helpers */
 double qdict_get_double(const QDict *qdict, const char *key);
-- 
2.14.1.146.gd35faa819


Re: [Qemu-devel] [PATCH v2 02/54] qdict: add qdict_put_null() helper
Posted by Markus Armbruster 8 years, 5 months ago
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/qapi/qmp/qdict.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
> index 363e431106..a35bed9f16 100644
> --- a/include/qapi/qmp/qdict.h
> +++ b/include/qapi/qmp/qdict.h
> @@ -60,6 +60,8 @@ void qdict_destroy_obj(QObject *obj);
   /* Helpers for int, bool, and string */
   #define qdict_put_int(qdict, key, value) \
           qdict_put(qdict, key, qnum_from_int(value))
   #define qdict_put_bool(qdict, key, value) \
>          qdict_put(qdict, key, qbool_from_bool(value))
>  #define qdict_put_str(qdict, key, value) \
>          qdict_put(qdict, key, qstring_from_str(value))
> +#define qdict_put_null(qdict, key) \
> +        qdict_put(qdict, key, qnull())
>  
>  /* High level helpers */
>  double qdict_get_double(const QDict *qdict, const char *key);

Marginal.  I can accept it for completeness's sake, or rather a step
towards completeness.  But please update the "Helpers for ..." comment,
and convert existing qdict_put(QD, K, qnull()) to use qdict_put_null().
A quick grep finds some in target/i386/cpu.c.  There might be more.

Re: [Qemu-devel] [PATCH v2 02/54] qdict: add qdict_put_null() helper
Posted by Eric Blake 8 years, 5 months ago
On 08/22/2017 10:09 AM, Markus Armbruster wrote:

>    #define qdict_put_bool(qdict, key, value) \
>>          qdict_put(qdict, key, qbool_from_bool(value))
>>  #define qdict_put_str(qdict, key, value) \
>>          qdict_put(qdict, key, qstring_from_str(value))
>> +#define qdict_put_null(qdict, key) \
>> +        qdict_put(qdict, key, qnull())
>>  
>>  /* High level helpers */
>>  double qdict_get_double(const QDict *qdict, const char *key);
> 
> Marginal.  I can accept it for completeness's sake, or rather a step
> towards completeness.  But please update the "Helpers for ..." comment,
> and convert existing qdict_put(QD, K, qnull()) to use qdict_put_null().
> A quick grep finds some in target/i386/cpu.c.  There might be more.

And we already used Coccinelle to find candidates for qdict_put_bool and
friends, so that should be the reasonable approach to use here as well.

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