diff options
author | Eric Blake <eblake@redhat.com> | 2021-01-13 16:10:13 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-01-28 08:08:45 +0100 |
commit | 95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3 (patch) | |
tree | 76d842228434aa8ac1dc10f8fcc4bfc5cce422d5 /softmmu | |
parent | c3033fd372fdaf5b89190136a74b3d78880b85d6 (diff) | |
download | qemu-95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3.zip qemu-95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3.tar.gz qemu-95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3.tar.bz2 |
qapi: More complex uses of QAPI_LIST_APPEND
These cases require a bit more thought to review; in each case, the
code was appending to a list, but not with a FOOList **tail variable.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210113221013.390592-6-eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Flawed change to qmp_guest_network_get_interfaces() dropped]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r-- | softmmu/tpm.c | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/softmmu/tpm.c b/softmmu/tpm.c index cab2063..578563f 100644 --- a/softmmu/tpm.c +++ b/softmmu/tpm.c @@ -196,22 +196,14 @@ int tpm_config_parse(QemuOptsList *opts_list, const char *optarg) TPMInfoList *qmp_query_tpm(Error **errp) { TPMBackend *drv; - TPMInfoList *info, *head = NULL, *cur_item = NULL; + TPMInfoList *head = NULL, **tail = &head; QLIST_FOREACH(drv, &tpm_backends, list) { if (!drv->tpmif) { continue; } - info = g_new0(TPMInfoList, 1); - info->value = tpm_backend_query_tpm(drv); - - if (!cur_item) { - head = cur_item = info; - } else { - cur_item->next = info; - cur_item = info; - } + QAPI_LIST_APPEND(tail, tpm_backend_query_tpm(drv)); } return head; @@ -220,44 +212,26 @@ TPMInfoList *qmp_query_tpm(Error **errp) TpmTypeList *qmp_query_tpm_types(Error **errp) { unsigned int i = 0; - TpmTypeList *head = NULL, *prev = NULL, *cur_item; + TpmTypeList *head = NULL, **tail = &head; for (i = 0; i < TPM_TYPE__MAX; i++) { if (!tpm_be_find_by_type(i)) { continue; } - cur_item = g_new0(TpmTypeList, 1); - cur_item->value = i; - - if (prev) { - prev->next = cur_item; - } - if (!head) { - head = cur_item; - } - prev = cur_item; + QAPI_LIST_APPEND(tail, i); } return head; } TpmModelList *qmp_query_tpm_models(Error **errp) { - TpmModelList *head = NULL, *prev = NULL, *cur_item; + TpmModelList *head = NULL, **tail = &head; GSList *e, *l = object_class_get_list(TYPE_TPM_IF, false); for (e = l; e; e = e->next) { TPMIfClass *c = TPM_IF_CLASS(e->data); - cur_item = g_new0(TpmModelList, 1); - cur_item->value = c->model; - - if (prev) { - prev->next = cur_item; - } - if (!head) { - head = cur_item; - } - prev = cur_item; + QAPI_LIST_APPEND(tail, c->model); } g_slist_free(l); |