From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VRRhU-0008Aj-5y for mharc-qemu-trivial@gnu.org; Wed, 02 Oct 2013 15:03:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRRhM-0007z3-P1 for qemu-trivial@nongnu.org; Wed, 02 Oct 2013 15:03:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRRhG-00057Z-QV for qemu-trivial@nongnu.org; Wed, 02 Oct 2013 15:03:00 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:55564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRRh3-00056I-VF; Wed, 02 Oct 2013 15:02:42 -0400 Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 63823405F1; Wed, 2 Oct 2013 23:02:40 +0400 (MSK) Message-ID: <524C6DD0.9070605@msgid.tls.msk.ru> Date: Wed, 02 Oct 2013 23:02:40 +0400 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9 MIME-Version: 1.0 To: Stefan Weil References: <1380469272-19230-1-git-send-email-sw@weilnetz.de> <52488A00.6000405@msgid.tls.msk.ru> <52488E98.3060505@weilnetz.de> <871u46iq96.fsf@blackfin.pond.sub.org> <5249E4CD.1050605@weilnetz.de> In-Reply-To: <5249E4CD.1050605@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial , Markus Armbruster , qemu-devel Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] migration: Fix compiler warning ('caps' may be used uninitialized) X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Oct 2013 19:03:06 -0000 How about this: diff --git a/migration.c b/migration.c index b4f8462..6066ab4 100644 --- a/migration.c +++ b/migration.c @@ -146,22 +146,16 @@ uint64_t migrate_max_downtime(void) MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { MigrationCapabilityStatusList *head = NULL; - MigrationCapabilityStatusList *caps; + MigrationCapabilityStatusList **capp = &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)); - caps = caps->next; - } - caps->value = - g_malloc(sizeof(*caps->value)); - caps->value->capability = i; - caps->value->state = s->enabled_capabilities[i]; + *capp = g_malloc0(sizeof(*head)); + (*capp)->value = g_malloc(sizeof(*head->value)); + (*capp)->value->capability = i; + (*capp)->value->state = s->enabled_capabilities[i]; + capp = &(*capp)->next; } return head; This is what I had in mind at the very beginnig, but only now tried to make a patch... Thanks, /mjt Thanks, From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRRhA-0007rL-Py for qemu-devel@nongnu.org; Wed, 02 Oct 2013 15:02:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRRh4-00056R-7K for qemu-devel@nongnu.org; Wed, 02 Oct 2013 15:02:48 -0400 Message-ID: <524C6DD0.9070605@msgid.tls.msk.ru> Date: Wed, 02 Oct 2013 23:02:40 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1380469272-19230-1-git-send-email-sw@weilnetz.de> <52488A00.6000405@msgid.tls.msk.ru> <52488E98.3060505@weilnetz.de> <871u46iq96.fsf@blackfin.pond.sub.org> <5249E4CD.1050605@weilnetz.de> In-Reply-To: <5249E4CD.1050605@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] migration: Fix compiler warning ('caps' may be used uninitialized) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: qemu-trivial , Markus Armbruster , qemu-devel How about this: diff --git a/migration.c b/migration.c index b4f8462..6066ab4 100644 --- a/migration.c +++ b/migration.c @@ -146,22 +146,16 @@ uint64_t migrate_max_downtime(void) MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { MigrationCapabilityStatusList *head = NULL; - MigrationCapabilityStatusList *caps; + MigrationCapabilityStatusList **capp = &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)); - caps = caps->next; - } - caps->value = - g_malloc(sizeof(*caps->value)); - caps->value->capability = i; - caps->value->state = s->enabled_capabilities[i]; + *capp = g_malloc0(sizeof(*head)); + (*capp)->value = g_malloc(sizeof(*head->value)); + (*capp)->value->capability = i; + (*capp)->value->state = s->enabled_capabilities[i]; + capp = &(*capp)->next; } return head; This is what I had in mind at the very beginnig, but only now tried to make a patch... Thanks, /mjt Thanks,