All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
To: Ingo Molnar <mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: "H. Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>,
	Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: Re: [GIT PULL] EFI changes for v4.2
Date: Tue, 2 Jun 2015 14:24:03 +0100	[thread overview]
Message-ID: <20150602132403.GB6826@codeblueprint.co.uk> (raw)
In-Reply-To: <20150602064557.GB31128-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Tue, 02 Jun, at 08:45:57AM, Ingo Molnar wrote:
> 
> Pulled, thanks a lot Matt!
> 
> I'm wondering about this commit:
> 
>   f2f6b587c553 ("efi/esrt: Fix some compiler warnings")
> 
> It says, in part:
> 
>  This patch also fixes one other warning about an uninitialized variable
>  some compiler versions seem to see.  You can't actually hit the code
>  path where it would be uninitialized, because there's a prior test that
>  would error out, but gcc hasn't figured that out.  Anyway, it now has a
>  test and returns the error at both places.
> 
> @@ -167,7 +167,6 @@ static struct kset *esrt_kset;
>  
>  static int esre_create_sysfs_entry(void *esre, int entry_num)
>  {
> -       int rc = 0;
>         struct esre_entry *entry;
>         char name[20];
>  
> @@ -180,13 +179,15 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
>         entry->kobj.kset = esrt_kset;
>  
>         if (esrt->fw_resource_version == 1) {
> +               int rc = 0;
> +
>                 entry->esre.esre1 = esre;
>                 rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL,
>                                           "%s", name);
> -       }
> -       if (rc) {
> -               kfree(entry);
> -               return rc;
> +               if (rc) {
> +                       kfree(entry);
> +                       return rc;
> +               }
>         }
>  
>         list_add_tail(&entry->list, &entry_list);
> 
> How can a compiler ever have warned about 'rc' being uninitialized? It's defined 
> straight at function entry, with initialization to 0. It can never be 
> uninitialized.
 
Hmm... yeah good point. I admit that I missed that when merging this
patch because I was focusing more on the fix for the kbuild warnings
related to phys_addr_t.

Peter? Where did you see gcc complaining about this?

-- 
Matt Fleming, Intel Open Source Technology Center

WARNING: multiple messages have this Message-ID (diff)
From: Matt Fleming <matt@codeblueprint.co.uk>
To: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Peter Jones <pjones@redhat.com>
Subject: Re: [GIT PULL] EFI changes for v4.2
Date: Tue, 2 Jun 2015 14:24:03 +0100	[thread overview]
Message-ID: <20150602132403.GB6826@codeblueprint.co.uk> (raw)
In-Reply-To: <20150602064557.GB31128@gmail.com>

On Tue, 02 Jun, at 08:45:57AM, Ingo Molnar wrote:
> 
> Pulled, thanks a lot Matt!
> 
> I'm wondering about this commit:
> 
>   f2f6b587c553 ("efi/esrt: Fix some compiler warnings")
> 
> It says, in part:
> 
>  This patch also fixes one other warning about an uninitialized variable
>  some compiler versions seem to see.  You can't actually hit the code
>  path where it would be uninitialized, because there's a prior test that
>  would error out, but gcc hasn't figured that out.  Anyway, it now has a
>  test and returns the error at both places.
> 
> @@ -167,7 +167,6 @@ static struct kset *esrt_kset;
>  
>  static int esre_create_sysfs_entry(void *esre, int entry_num)
>  {
> -       int rc = 0;
>         struct esre_entry *entry;
>         char name[20];
>  
> @@ -180,13 +179,15 @@ static int esre_create_sysfs_entry(void *esre, int entry_num)
>         entry->kobj.kset = esrt_kset;
>  
>         if (esrt->fw_resource_version == 1) {
> +               int rc = 0;
> +
>                 entry->esre.esre1 = esre;
>                 rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL,
>                                           "%s", name);
> -       }
> -       if (rc) {
> -               kfree(entry);
> -               return rc;
> +               if (rc) {
> +                       kfree(entry);
> +                       return rc;
> +               }
>         }
>  
>         list_add_tail(&entry->list, &entry_list);
> 
> How can a compiler ever have warned about 'rc' being uninitialized? It's defined 
> straight at function entry, with initialization to 0. It can never be 
> uninitialized.
 
Hmm... yeah good point. I admit that I missed that when merging this
patch because I was focusing more on the fix for the kbuild warnings
related to phys_addr_t.

Peter? Where did you see gcc complaining about this?

-- 
Matt Fleming, Intel Open Source Technology Center

  parent reply	other threads:[~2015-06-02 13:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-31 16:25 [GIT PULL] EFI changes for v4.2 Matt Fleming
2015-05-31 16:25 ` Matt Fleming
2015-06-02  6:45 ` Ingo Molnar
     [not found]   ` <20150602064557.GB31128-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-02 13:24     ` Matt Fleming [this message]
2015-06-02 13:24       ` Matt Fleming
2015-06-02 13:59   ` Peter Jones
     [not found]     ` <20150602135944.GB29523-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-03  6:22       ` Ingo Molnar
2015-06-03  6:22         ` Ingo Molnar

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=20150602132403.GB6826@codeblueprint.co.uk \
    --to=matt-mf/unelci9gs6ibeejttw/xrex20p6io@public.gmane.org \
    --cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
    /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.