qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-trivial] [PATCH] migration: Fix compiler warning


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH] migration: Fix compiler warning ('caps' may be used uninitialized)
Date: Thu, 03 Oct 2013 10:13:57 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9

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




reply via email to

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