[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 3/6] qlist: Add convenience helpers for wrapp
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH v2 3/6] qlist: Add convenience helpers for wrapped appends |
Date: |
Thu, 19 Jan 2017 09:08:19 +0000 |
Hi
On Wed, Jan 18, 2017 at 8:34 PM Eric Blake <address@hidden> wrote:
> Similar to the qdict additions of the previous patch, although
> this time there are not as many clients.
>
> Signed-off-by: Eric Blake <address@hidden>
>
Not very useful, but why not:
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> include/qapi/qmp/qlist.h | 8 ++++++++
> tests/check-qdict.c | 10 +++++-----
> tests/check-qlist.c | 2 +-
> 3 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
> index a84117e..659325a 100644
> --- a/include/qapi/qmp/qlist.h
> +++ b/include/qapi/qmp/qlist.h
> @@ -29,6 +29,14 @@ typedef struct QList {
> #define qlist_append(qlist, obj) \
> qlist_append_obj(qlist, QOBJECT(obj))
>
> +/* Helpers for int, bool, and const char*. */
> +#define qlist_append_int(qlist, value) \
> + qlist_append(qlist, qint_from_int(value))
> +#define qlist_append_bool(qlist, value) \
> + qlist_append(qlist, qbool_from_bool(value))
> +#define qlist_append_str(qlist, value) \
> + qlist_append(qlist, qstring_from_str(value))
> +
> #define QLIST_FOREACH_ENTRY(qlist, var) \
> for ((var) = ((qlist)->head.tqh_first); \
> (var); \
> diff --git a/tests/check-qdict.c b/tests/check-qdict.c
> index d00b411..6d4f8a7 100644
> --- a/tests/check-qdict.c
> +++ b/tests/check-qdict.c
> @@ -297,11 +297,11 @@ static void qdict_flatten_test(void)
> qdict_put_int(dict1, "a", 0);
> qdict_put_int(dict1, "b", 1);
>
> - qlist_append_obj(list1, QOBJECT(qint_from_int(23)));
> - qlist_append_obj(list1, QOBJECT(qint_from_int(66)));
> - qlist_append_obj(list1, QOBJECT(dict1));
> - qlist_append_obj(list2, QOBJECT(qint_from_int(42)));
> - qlist_append_obj(list2, QOBJECT(list1));
> + qlist_append_int(list1, 23);
> + qlist_append_int(list1, 66);
> + qlist_append(list1, dict1);
> + qlist_append_int(list2, 42);
> + qlist_append(list2, list1);
>
> qdict_put_int(dict2, "c", 2);
> qdict_put_int(dict2, "d", 3);
> diff --git a/tests/check-qlist.c b/tests/check-qlist.c
> index e16da5e..38463f1 100644
> --- a/tests/check-qlist.c
> +++ b/tests/check-qlist.c
> @@ -74,7 +74,7 @@ static void qlist_destroy_test(void)
> qlist = qlist_new();
>
> for (i = 0; i < 42; i++)
> - qlist_append(qlist, qint_from_int(i));
> + qlist_append_int(qlist, i);
>
> QDECREF(qlist);
> }
> --
> 2.9.3
>
>
> --
Marc-André Lureau
- [Qemu-devel] [PATCH v2 0/6] qapi-related cleanups, Eric Blake, 2017/01/18
- [Qemu-devel] [PATCH v2 1/6] pci: Use struct instead of QDict to pass back parameters, Eric Blake, 2017/01/18
- [Qemu-devel] [PATCH v2 6/6] qapi: Promote blockdev-change-medium arguments to QAPI type, Eric Blake, 2017/01/18
- [Qemu-devel] [PATCH v2 3/6] qlist: Add convenience helpers for wrapped appends, Eric Blake, 2017/01/18
- Re: [Qemu-devel] [PATCH v2 3/6] qlist: Add convenience helpers for wrapped appends,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v2 5/6] test-qga: Actually test 0xff sync bytes, Eric Blake, 2017/01/18
- [Qemu-devel] [PATCH v2 4/6] fdc-test: Avoid deprecated 'change' command, Eric Blake, 2017/01/18
- [Qemu-devel] [PATCH v2 2/6] qdict: Add convenience helpers for wrapped puts, Eric Blake, 2017/01/18