aboutsummaryrefslogtreecommitdiff
path: root/softmmu/tpm.c
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 /softmmu/tpm.c
parent0bcd12fb1513bad44f05f2d3a8eef2a99b3077b6 (diff)
parent95b3a8c8a82a34ca874ac0d4a9bbbdb38034acf3 (diff)
downloadqemu-7e7eb9f852a46b51a71ae9d82590b2e4d28827ee.zip
qemu-7e7eb9f852a46b51a71ae9d82590b2e4d28827ee.tar.gz
qemu-7e7eb9f852a46b51a71ae9d82590b2e4d28827ee.tar.bz2
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 'softmmu/tpm.c')
-rw-r--r--softmmu/tpm.c38
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);