Hi On Wed, Jan 18, 2017 at 8:34 PM Eric Blake <[email protected]> wrote:
> Similar to the qdict additions of the previous patch, although > this time there are not as many clients. > > Signed-off-by: Eric Blake <[email protected]> > Not very useful, but why not: Reviewed-by: Marc-André Lureau <[email protected]> > --- > 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
