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>
This commit is contained in:
Eric Blake 2021-01-13 16:10:12 -06:00 committed by Markus Armbruster
parent dc13f40c6b
commit c3033fd372
20 changed files with 96 additions and 222 deletions

View file

@ -76,20 +76,20 @@ void hmp_handle_error(Monitor *mon, Error *err)
static strList *strList_from_comma_list(const char *in)
{
strList *res = NULL;
strList **hook = &res;
strList **tail = &res;
while (in && in[0]) {
char *comma = strchr(in, ',');
*hook = g_new0(strList, 1);
char *value;
if (comma) {
(*hook)->value = g_strndup(in, comma - in);
value = g_strndup(in, comma - in);
in = comma + 1; /* skip the , */
} else {
(*hook)->value = g_strdup(in);
value = g_strdup(in);
in = NULL;
}
hook = &(*hook)->next;
QAPI_LIST_APPEND(tail, value);
}
return res;