All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Cc: qemu-devel@nongnu.org, aliguori@amazon.com
Subject: Re: [Qemu-devel] [PATCH] vl: Fix compile issue with Werror option
Date: Sat, 21 Dec 2013 11:46:16 +0100	[thread overview]
Message-ID: <87fvpmlbwn.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1387520990-3228-1-git-send-email-qiudayu@linux.vnet.ibm.com> (Mike Qiu's message of "Fri, 20 Dec 2013 01:29:50 -0500")

Mike Qiu <qiudayu@linux.vnet.ibm.com> writes:

> Currently, if compile with Werror option, the error message shows
> below:
>
>   GEN   config-host.h
>   GEN   trace/generated-tracers.h
>         CHK version_gen.h
>   GEN   trace/generated-tracers.c
>   CC    vl.o
> vl.c: In function ‘get_boot_devices_list’:
> vl.c:1257:21: error: ‘bootpath’ may be used uninitialized
> 	in this function [-Werror=maybe-uninitialized]
>          len = strlen(bootpath) + 1;
>                      ^
> cc1: all warnings being treated as errors
> make: *** [vl.o] Error 1
>
> This patch is to solve this issue.
>
> Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com>
> ---
>  vl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/vl.c b/vl.c
> index b97728f..d67b284 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1230,7 +1230,7 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
>      char *list = NULL;
>  
>      QTAILQ_FOREACH(i, &fw_boot_order, link) {
> -        char *devpath = NULL, *bootpath;
> +        char *devpath = NULL, *bootpath = NULL;
>          size_t len;
>  
>          if (i->dev) {

Compiler version?  I'm asking because bootpath looks quite defined on
all paths leading to the line you quoted:

    QTAILQ_FOREACH(i, &fw_boot_order, link) {
        char *devpath = NULL, *bootpath;
        size_t len;

        if (i->dev) {
            devpath = qdev_get_fw_dev_path(i->dev);
            assert(devpath);
        }

        if (i->suffix && devpath) {
            size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;

--->        bootpath = g_malloc(bootpathlen);
            snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
            g_free(devpath);
        } else if (devpath) {
--->        bootpath = devpath;
        } else {
            assert(i->suffix);
--->        bootpath = g_strdup(i->suffix);
        }

        if (total) {
            list[total-1] = '\n';
        }
        len = strlen(bootpath) + 1;

      reply	other threads:[~2013-12-21 10:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20  6:29 [Qemu-devel] [PATCH] vl: Fix compile issue with Werror option Mike Qiu
2013-12-21 10:46 ` Markus Armbruster [this message]

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=87fvpmlbwn.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qiudayu@linux.vnet.ibm.com \
    /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.