qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [PATCH v6 11/11] qapi: Use QAPI_LIST_ADD() where possible
Date: Tue, 27 Oct 2020 16:42:05 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

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@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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]