Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6579663ybi; Sun, 21 Jul 2019 21:22:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXBe4+cEBvQ1RiT0oLOcPx/riZ9tA6T8Qrx6SvnKth/0cx0bJG6d270s8gAWzLQdzThgtQ X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr63575068plp.245.1563769363544; Sun, 21 Jul 2019 21:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563769363; cv=none; d=google.com; s=arc-20160816; b=O5y9MAlSORPPp1L6+Q0tWwcZNOelwpCc2IhBWh+opATc8f74NAMAmmwx+mi5yZUEHN 2TQpWSxDdnqsNebb4v2eUqqW4qoraUcUSgJCtSAy7WAG8tOH4V8CYIC1Ipj7tRuXJBB2 f1ENG4Trbz2/0NaFD7zFjlTsQezBgK3rXeGoZIP+/SyPwcJ5sO1U/jypjvXFD/jE6/AG vvRij4u/BBnRYly5CgvXybRJChMqdiktLbo4KcuKHC3wavGFxoUS2CF6+bN0fJkDY4Yc dHefUDxXCJRFCnrSli6iq3py67DVOZLzNPwgtrABSkwvB4RfmV2BYv8Z/mO0M7yBiVq5 WnIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=wq7DBkdHgBXxblgVfGylp4K+2sZn7n+C6pE2nNGDJXo=; b=iLcml54hjaNl/eQeIy6feEcgstEDOJnNiuF5Mn+mz9T1+ngfVQfNHta0bSEgMHL2Vp Slwab5vTrZwSF8l9UWQpDc6FIcx7nuJLLA/iFPbHgB1IAfT3L1E8MI6rbTUgB53LscVF I/qAxQYbrtB3oe/mc0TOdRZyfbroxRV1WJdGLcQT2B3ycP+Nttua3VRIuS9vlfrVY+/I 0WFMbmvFOUFlA9wALtCRYM+mDq+eP/Iis4b2CBIScuF8/nZFZHo0HdOy0ci65oVf1kmv C+DzsqZ3nqSMbId6qafNW2E5oaHxR4yIdI2Gp+TEPHQcfYSPJST1JL2cP0uXB8ODMmdT TGNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v33si39896910pgk.152.2019.07.21.21.22.27; Sun, 21 Jul 2019 21:22:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727403AbfGVEFR (ORCPT + 99 others); Mon, 22 Jul 2019 00:05:17 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:60035 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726994AbfGVEFR (ORCPT ); Mon, 22 Jul 2019 00:05:17 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45sSgY228dz9s4Y; Mon, 22 Jul 2019 14:05:13 +1000 (AEST) From: Michael Ellerman To: Nathan Chancellor , Tyrel Datwyler , Benjamin Herrenschmidt , Paul Mackerras Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nick Desaulniers Subject: Re: [PATCH v2] PCI: rpaphp: Avoid a sometimes-uninitialized warning In-Reply-To: <20190722024313.GB55142@archlinux-threadripper> References: <20190603174323.48251-1-natechancellor@gmail.com> <20190603221157.58502-1-natechancellor@gmail.com> <20190722024313.GB55142@archlinux-threadripper> Date: Mon, 22 Jul 2019 14:05:12 +1000 Message-ID: <87lfwq7lzb.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nathan Chancellor writes: > On Mon, Jun 03, 2019 at 03:11:58PM -0700, Nathan Chancellor wrote: >> When building with -Wsometimes-uninitialized, clang warns: >> >> drivers/pci/hotplug/rpaphp_core.c:243:14: warning: variable 'fndit' is >> used uninitialized whenever 'for' loop exits because its condition is >> false [-Wsometimes-uninitialized] >> for (j = 0; j < entries; j++) { >> ^~~~~~~~~~~ >> drivers/pci/hotplug/rpaphp_core.c:256:6: note: uninitialized use occurs >> here >> if (fndit) >> ^~~~~ >> drivers/pci/hotplug/rpaphp_core.c:243:14: note: remove the condition if >> it is always true >> for (j = 0; j < entries; j++) { >> ^~~~~~~~~~~ >> drivers/pci/hotplug/rpaphp_core.c:233:14: note: initialize the variable >> 'fndit' to silence this warning >> int j, fndit; >> ^ >> = 0 >> >> fndit is only used to gate a sprintf call, which can be moved into the >> loop to simplify the code and eliminate the local variable, which will >> fix this warning. >> >> Link: https://github.com/ClangBuiltLinux/linux/issues/504 >> Fixes: 2fcf3ae508c2 ("hotplug/drc-info: Add code to search ibm,drc-info property") >> Suggested-by: Nick Desaulniers >> Signed-off-by: Nathan Chancellor >> --- >> >> v1 -> v2: >> >> * Eliminate fndit altogether by shuffling the sprintf call into the for >> loop and changing the if conditional, as suggested by Nick. >> >> drivers/pci/hotplug/rpaphp_core.c | 18 +++++++----------- >> 1 file changed, 7 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c >> index bcd5d357ca23..c3899ee1db99 100644 >> --- a/drivers/pci/hotplug/rpaphp_core.c >> +++ b/drivers/pci/hotplug/rpaphp_core.c >> @@ -230,7 +230,7 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, >> struct of_drc_info drc; >> const __be32 *value; >> char cell_drc_name[MAX_DRC_NAME_LEN]; >> - int j, fndit; >> + int j; >> >> info = of_find_property(dn->parent, "ibm,drc-info", NULL); >> if (info == NULL) >> @@ -245,17 +245,13 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, >> >> /* Should now know end of current entry */ >> >> - if (my_index > drc.last_drc_index) >> - continue; >> - >> - fndit = 1; >> - break; >> + /* Found it */ >> + if (my_index <= drc.last_drc_index) { >> + sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, >> + my_index); >> + break; >> + } >> } >> - /* Found it */ >> - >> - if (fndit) >> - sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, >> - my_index); >> >> if (((drc_name == NULL) || >> (drc_name && !strcmp(drc_name, cell_drc_name))) && >> -- >> 2.22.0.rc3 >> > > Hi all, > > Could someone please pick this up? I'll take it. I was expecting Bjorn to take it as a PCI patch, but I realise now that I merged that code in the first place so may as well take this too. I'll put it in my next branch once that opens next week. cheers