diff options
author | Eric Blake <eblake@redhat.com> | 2021-01-13 16:10:12 -0600 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2021-01-28 08:08:45 +0100 |
commit | c3033fd372fdaf5b89190136a74b3d78880b85d6 (patch) | |
tree | 6c2464ae3f51b43702c448606acb3a6c21b6b634 /target/i386 | |
parent | dc13f40c6ba291e31d09053815c230ed88c8921f (diff) | |
download | qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.zip qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.gz qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.bz2 |
qapi: Use QAPI_LIST_APPEND in trivial cases
The easiest spots to use QAPI_LIST_APPEND are where we already have an
obvious pointer to the tail of a list. While at it, consistently use
the variable name 'tail' for that purpose.
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20210113221013.390592-5-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'target/i386')
-rw-r--r-- | target/i386/cpu.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 72a79e6..ae89024 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4818,20 +4818,17 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose); /* Build a list with the name of all features on a feature word array */ static void x86_cpu_list_feature_names(FeatureWordArray features, - strList **feat_names) + strList **list) { + strList **tail = list; FeatureWord w; - strList **next = feat_names; for (w = 0; w < FEATURE_WORDS; w++) { uint64_t filtered = features[w]; int i; for (i = 0; i < 64; i++) { if (filtered & (1ULL << i)) { - strList *new = g_new0(strList, 1); - new->value = g_strdup(x86_cpu_feature_name(w, i)); - *next = new; - next = &new->next; + QAPI_LIST_APPEND(tail, g_strdup(x86_cpu_feature_name(w, i))); } } } @@ -4852,16 +4849,14 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v, * running using the current machine and accelerator. */ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, - strList **missing_feats) + strList **list) { + strList **tail = list; X86CPU *xc; Error *err = NULL; - strList **next = missing_feats; if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) { - strList *new = g_new0(strList, 1); - new->value = g_strdup("kvm"); - *missing_feats = new; + QAPI_LIST_APPEND(tail, g_strdup("kvm")); return; } @@ -4873,16 +4868,13 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, * but in case it does, just report the model as not * runnable at all using the "type" property. */ - strList *new = g_new0(strList, 1); - new->value = g_strdup("type"); - *next = new; - next = &new->next; + QAPI_LIST_APPEND(tail, g_strdup("type")); error_free(err); } x86_cpu_filter_features(xc, false); - x86_cpu_list_feature_names(xc->filtered_features, next); + x86_cpu_list_feature_names(xc->filtered_features, tail); object_unref(OBJECT(xc)); } |