[GEDI] [PATCH v6 11/11] qapi: Use QAPI_LIST_ADD() where possible

Vladimir Sementsov-Ogievskiy vsementsov at virtuozzo.com
Tue Oct 27 13:42:05 UTC 2020


27.10.2020 08:05, Eric Blake wrote:
> Anywhere we create a list of just one item or by prepending items
> (typically because order doesn't matter), we can use the now-public
> macro.  But places where we must keep the list in order by appending
> remain open-coded.
> 
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---

[..]

> 
> diff --git a/docs/devel/writing-qmp-commands.txt b/docs/devel/writing-qmp-commands.txt
> index 46a6c48683f5..3e11eeaa1893 100644
> --- a/docs/devel/writing-qmp-commands.txt
> +++ b/docs/devel/writing-qmp-commands.txt
> @@ -531,15 +531,10 @@ TimerAlarmMethodList *qmp_query_alarm_methods(Error **errp)
>       bool current = true;
> 
>       for (p = alarm_timers; p->name; p++) {
> -        TimerAlarmMethodList *info = g_malloc0(sizeof(*info));
> -        info->value = g_malloc0(sizeof(*info->value));
> -        info->value->method_name = g_strdup(p->name);
> -        info->value->current = current;
> -
> -        current = false;

You need to keep this line, otherwise logic is broken.

> -
> -        info->next = method_list;
> -        method_list = info;
> +	TimerAlarmMethod *value = g_new0(TimerAlarmMethod, 1);
> +        value->method_name = g_strdup(p->name);
> +        value->current = current;
> +        QAPI_LIST_ADD(method_list, value);
>       }
> 
>       return method_list;



-- 
Best regards,
Vladimir


More information about the integration mailing list