qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: Fix compiler warning ('caps' may be used uninitialized)
@ 2013-09-29 15:41 Stefan Weil
  2013-09-29 20:13 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  2013-10-01 11:39 ` [Qemu-devel] " Paolo Bonzini
  0 siblings, 2 replies; 13+ messages in thread
From: Stefan Weil @ 2013-09-29 15:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Stefan Weil

The QEMU buildbot default_i386_debian_6_0 shows this warning:

  CC    migration.o
migration.c: In function 'qmp_query_migrate_capabilities':
migration.c:149: warning:
 'caps' may be used uninitialized in this function

While changing this code, I also replaced g_malloc0
by the type safe g_new0.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---

Buildbot URL:
http://buildbot.b1-systems.de/qemu/builders/default_i386_debian_6_0/builds/775/steps/compile/logs/stdio

 migration.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/migration.c b/migration.c
index 200d404..8dcb6ce 100644
--- a/migration.c
+++ b/migration.c
@@ -145,17 +145,15 @@ uint64_t migrate_max_downtime(void)
 
 MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
 {
-    MigrationCapabilityStatusList *head = NULL;
-    MigrationCapabilityStatusList *caps;
+    MigrationCapabilityStatusList *head =
+        g_new0(MigrationCapabilityStatusList, 1);
+    MigrationCapabilityStatusList *caps = head;
     MigrationState *s = migrate_get_current();
     int i;
 
     for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) {
-        if (head == NULL) {
-            head = g_malloc0(sizeof(*caps));
-            caps = head;
-        } else {
-            caps->next = g_malloc0(sizeof(*caps));
+        if (i > 0) {
+            caps->next = g_new0(MigrationCapabilityStatusList, i);
             caps = caps->next;
         }
         caps->value =
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-10-05  9:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-29 15:41 [Qemu-devel] [PATCH] migration: Fix compiler warning ('caps' may be used uninitialized) Stefan Weil
2013-09-29 20:13 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2013-09-29 20:33   ` Stefan Weil
2013-09-30  9:59     ` Markus Armbruster
2013-09-30 20:53       ` Stefan Weil
2013-10-01  8:07         ` Markus Armbruster
2013-10-02 19:02         ` Michael Tokarev
2013-10-02 20:24           ` Stefan Weil
2013-10-03  8:13             ` Paolo Bonzini
2013-10-05  9:15               ` Michael Tokarev
2013-10-05  9:19                 ` Michael Tokarev
2013-10-05  9:36                   ` Stefan Weil
2013-10-01 11:39 ` [Qemu-devel] " Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).