Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753851AbbFCGXX (ORCPT ); Wed, 3 Jun 2015 02:23:23 -0400 Received: from mail-wi0-f182.google.com ([209.85.212.182]:36271 "EHLO mail-wi0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753277AbbFCGWx (ORCPT ); Wed, 3 Jun 2015 02:22:53 -0400 Date: Wed, 3 Jun 2015 08:22:48 +0200 From: Ingo Molnar To: Peter Jones Cc: Matt Fleming , "H. Peter Anvin" , Thomas Gleixner , linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [GIT PULL] EFI changes for v4.2 Message-ID: <20150603062247.GA24639@gmail.com> References: <20150531162559.GA6826@codeblueprint.co.uk> <20150602064557.GB31128@gmail.com> <20150602135944.GB29523@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150602135944.GB29523@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2690 Lines: 68 * Peter Jones wrote: > On Tue, Jun 02, 2015 at 08:45:57AM +0200, Ingo Molnar wrote: > > @@ -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. > > > > I pulled it, because I agree with the change itself, as it's always better to > > define and use variables in the narrowest scope possible, but I think it's a > > cleanup, not a compiler warning fix. > > Well, apparently I failed to explain it well - the warning was about > "esre" rather than "rc". Basically before we were testing the version in > register_entries() (i.e. this function's caller) and never calling the > this function if it's not version 1. The compiler didn't figure out > that when we set "entry->esre.esre1 = esre;", esre can not be null > because the function wouldn't be called. Adding the explicit check > on the version here silenced the warning about entry plausibly being > NULL. > > I'm guessing that this is because it's checking that the same > conditional test is involved - that the initialization is in the same > "...version == 1" test that the usage is. But that's just a guess. > > Would you like another patch to add this email to the commit message, or do you > want to add it in your tree, or what? No need, I already pulled, because the changes themselves seemed OK - just wanted to ask in case there's something subtle going on. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/