diff options
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 cab206355a..578563f05a 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); |