All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	Michael Tokarev <mjt@tls.msk.ru>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] migration: Fix compiler warning ('caps' may be used uninitialized)
Date: Thu, 03 Oct 2013 10:13:57 +0200	[thread overview]
Message-ID: <524D2745.8060906@redhat.com> (raw)
In-Reply-To: <524C80ED.3020507@weilnetz.de>

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



WARNING: multiple messages have this Message-ID (diff)
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-trivial <qemu-trivial@nongnu.org>,
	Michael Tokarev <mjt@tls.msk.ru>,
	Markus Armbruster <armbru@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
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	[thread overview]
Message-ID: <524D2745.8060906@redhat.com> (raw)
In-Reply-To: <524C80ED.3020507@weilnetz.de>

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	other threads:[~2013-10-03  8:13 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=524D2745.8060906@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.