aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-01-28 22:43:18 +0000
committerPeter Maydell <peter.maydell@linaro.org>2021-01-28 22:43:18 +0000
commit7e7eb9f852a46b51a71ae9d82590b2e4d28827ee (patch)
treed63017ecda357d29659abe087aa6a09d808b06b5 /tests
parent0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6 (diff)
parent95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3 (diff)
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging
QAPI patches patches for 2021-01-28 # gpg: Signature made Thu 28 Jan 2021 07:10:21 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-01-28: qapi: More complex uses of QAPI_LIST_APPEND qapi: Use QAPI_LIST_APPEND in trivial cases qapi: Introduce QAPI_LIST_APPEND qapi: A couple more QAPI_LIST_PREPEND() stragglers net: Clarify early exit condition Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/test-qobject-output-visitor.c84
-rw-r--r--tests/test-string-output-visitor.c6
2 files changed, 26 insertions, 64 deletions
diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c
index b20ab8b29b..9dc1e075e7 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -442,122 +442,86 @@ static void init_list_union(UserDefListUnion *cvalue)
int i;
switch (cvalue->type) {
case USER_DEF_LIST_UNION_KIND_INTEGER: {
- intList **list = &cvalue->u.integer.data;
+ intList **tail = &cvalue->u.integer.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(intList, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_S8: {
- int8List **list = &cvalue->u.s8.data;
+ int8List **tail = &cvalue->u.s8.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(int8List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_S16: {
- int16List **list = &cvalue->u.s16.data;
+ int16List **tail = &cvalue->u.s16.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(int16List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_S32: {
- int32List **list = &cvalue->u.s32.data;
+ int32List **tail = &cvalue->u.s32.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(int32List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_S64: {
- int64List **list = &cvalue->u.s64.data;
+ int64List **tail = &cvalue->u.s64.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(int64List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_U8: {
- uint8List **list = &cvalue->u.u8.data;
+ uint8List **tail = &cvalue->u.u8.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(uint8List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_U16: {
- uint16List **list = &cvalue->u.u16.data;
+ uint16List **tail = &cvalue->u.u16.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(uint16List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_U32: {
- uint32List **list = &cvalue->u.u32.data;
+ uint32List **tail = &cvalue->u.u32.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(uint32List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_U64: {
- uint64List **list = &cvalue->u.u64.data;
+ uint64List **tail = &cvalue->u.u64.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(uint64List, 1);
- (*list)->value = i;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, i);
}
break;
}
case USER_DEF_LIST_UNION_KIND_BOOLEAN: {
- boolList **list = &cvalue->u.boolean.data;
+ boolList **tail = &cvalue->u.boolean.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(boolList, 1);
- (*list)->value = QEMU_IS_ALIGNED(i, 3);
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, QEMU_IS_ALIGNED(i, 3));
}
break;
}
case USER_DEF_LIST_UNION_KIND_STRING: {
- strList **list = &cvalue->u.string.data;
+ strList **tail = &cvalue->u.string.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(strList, 1);
- (*list)->value = g_strdup_printf("%d", i);
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, g_strdup_printf("%d", i));
}
break;
}
case USER_DEF_LIST_UNION_KIND_NUMBER: {
- numberList **list = &cvalue->u.number.data;
+ numberList **tail = &cvalue->u.number.data;
for (i = 0; i < 32; i++) {
- *list = g_new0(numberList, 1);
- (*list)->value = (double)i / 3;
- (*list)->next = NULL;
- list = &(*list)->next;
+ QAPI_LIST_APPEND(tail, (double)i / 3);
}
break;
}
diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index 0dae04b960..e2bedc5c7c 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -88,15 +88,13 @@ static void test_visitor_out_intList(TestOutputVisitorData *data,
{
int64_t value[] = {0, 1, 9, 10, 16, 15, 14,
3, 4, 5, 6, 11, 12, 13, 21, 22, INT64_MAX - 1, INT64_MAX};
- intList *list = NULL, **tmp = &list;
+ intList *list = NULL, **tail = &list;
int i;
Error *err = NULL;
char *str;
for (i = 0; i < ARRAY_SIZE(value); i++) {
- *tmp = g_malloc0(sizeof(**tmp));
- (*tmp)->value = value[i];
- tmp = &(*tmp)->next;
+ QAPI_LIST_APPEND(tail, value[i]);
}
visit_type_intList(data->ov, NULL, &list, &err);