From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRe2q-0000Yl-33 for qemu-devel@nongnu.org; Thu, 03 Oct 2013 04:14:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRe2k-0006XF-26 for qemu-devel@nongnu.org; Thu, 03 Oct 2013 04:14:00 -0400 Message-ID: <524D2745.8060906@redhat.com> Date: Thu, 03 Oct 2013 10:13:57 +0200 From: Paolo Bonzini 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> <524C6DD0.9070605@msgid.tls.msk.ru> <524C80ED.3020507@weilnetz.de> In-Reply-To: <524C80ED.3020507@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-15 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 , Michael Tokarev , Markus Armbruster , qemu-devel Il 02/10/2013 22:24, Stefan Weil ha scritto: > Am 02.10.2013 21:02, schrieb Michael Tokarev: > MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) > { > MigrationCapabilityStatusList *head = NULL; > MigrationCapabilityStatusList *prev = NULL; > MigrationState *s = migrate_get_current(); > MigrationCapability i; > > for (i = 0; i < MIGRATION_CAPABILITY_MAX; i++) { > MigrationCapabilityStatusList *caps = > g_new(MigrationCapabilityStatusList, 1); > if (prev == NULL) { > head = caps; > } else { > prev->next = caps; > prev = caps; > } > caps->value = g_new(MigrationCapabilityStatus, 1); > caps->value->capability = i; > caps->value->state = s->enabled_capabilities[i]; > } > > return head; > } I dislike having head initialized to NULL. > Which one do we take? Any correct solution which fixes the compiler > warning is fine for me (although I prefer g_new instead of g_malloc as > you might have guessed). :-) Mine uses g_new0 so it should work for you as well? :) Paolo