Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2437418ybd; Thu, 27 Jun 2019 12:19:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYovGRB7fzahZubBQcRw/nK4aqHX9GeLyB/dsVtyBQImOrA8Yf3q588mYftQBdfqvW9zbQ X-Received: by 2002:a17:902:b592:: with SMTP id a18mr6618199pls.278.1561663172221; Thu, 27 Jun 2019 12:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561663172; cv=none; d=google.com; s=arc-20160816; b=SqfSS6gKsw3ncboxeMFfTID6GsuPJYvi7/Lgrn5c8GOq+i16fwPzkwBHffGYL2G3XA zZrYqlJASPXhIjkKNfSUalCkU9y/JUQEWI9LBUl5vvJBo9DiVGDwWqhs6QG0eB6vOR+Y TQk1GVyciiO4t0kdvGthQ1IiGSUuvyU9cOrfM9yMFU/49nJst57RPMm1nIBK9TieZvtZ XwCTERfrpmRH0AIA+4d2MCqSCostsUXF7iP9iNAOT2h0HgANULzR0QANXQhPwV++xmKw vha8D8IFiLacDgQ/sUVc6/oSjoouo3DK61LsCMWj4KeCNTDyahlZ63c4vtInXiE8laq/ eugA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=V9/DvrSm1tuMxgh9gCPc5feOBQeRzRI5OCgy1Wf79Gk=; b=ffufOzlvY2CPC9EmGxwjtesrp46GJPrLLeiz5QZ3BL4+8xb4YWqwkOc09Awj0B2XUu 7EmdHldp6xLw1jYVciUWYJqEoWjRf1Vy+oL6F2MTyHW2zfPZ4Xwi1DZTv2CrekTODkxK EjuHWXpLuQ65Kn3khmcJfkERMNodHn6fBSPcDCzcsV6p8NczvpWM7dZuH1VdmA5vVXEY UPPlLUIgDUy1W3f8xx4lUp52v5d+OxAR1PszA5ETvZphQ+NQBi9VhzGbfEL8qNVRmEDj 7xjFoB4Dk/C/TMCYDI5RWJyYCx65MwC5ZYq/dgPXEXMUJqiD9BHIYCjjscbmTGatxoPw csEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gecuNsfA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si412218pfi.240.2019.06.27.12.19.16; Thu, 27 Jun 2019 12:19:32 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gecuNsfA; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbfF0TSm (ORCPT + 99 others); Thu, 27 Jun 2019 15:18:42 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46438 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbfF0TSl (ORCPT ); Thu, 27 Jun 2019 15:18:41 -0400 Received: by mail-ed1-f66.google.com with SMTP id d4so8109281edr.13; Thu, 27 Jun 2019 12:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=V9/DvrSm1tuMxgh9gCPc5feOBQeRzRI5OCgy1Wf79Gk=; b=gecuNsfA+4DkKar9EsBNVwySmvxGtn5QjxCfGe0pL3C8P5PP1Xy2qhhhZDcoqqpsMt o6a5PIeN7eNQMIhzmvUeQoUvUM6ihzgxXWIq70u7fu9iVoHK0FzMDxAxRgwfjJ4Y/0Np eAncgvXBOQ0xmiVv1lecus3bfWyVdHk5VwzGFxCT2/GbeqlKb/P18E1rbb80hy5diF/H 4YdJAru4bKV8H2mbVgheU4JQmdx7/dddyh73C9Mp5lr4a6BOUu8eCcrxqeIzo0SKJiFZ 5sPJgJAVAr2Bwv73DAJQk97UYRN7q89boMhZV+hgUVehyd/t4CV8IjUq7W/y3RK4iS23 l2yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=V9/DvrSm1tuMxgh9gCPc5feOBQeRzRI5OCgy1Wf79Gk=; b=TP+oXsWK9wC0B3f6/oM6FMEKVdaf7abZmk6PpmmArXpRLFar6AygTpJfa2GlzqUZ8+ am2lC4cQwvPp9OvFT/jpek6JwQ5UwKbPEi+BoyCwOsXvAHWo9CJWlmOHzvjVjN+DMLXf 3K6xbQldBZi9gIsUR3nYIG7HBXY4mPPwqbHQDIW6Hc/fXK0RHWPnYcqqjWkfEkxz2fUK Ul4N+qpehdDaPo0BVjWgurzS7pExxQk3Oe3tR2ArDctMUNIv1gEX44B1Cad+Pq/EQkpT vxlxBA0iewrIHuAfYnyWUXg66rUNNYYyg/ocX+EJ4ClwrfMPUr+fK3GeqZrx5Jq43fdP VJsQ== X-Gm-Message-State: APjAAAWkrxL/xlwj60944GO6mM6IlJ1MUYSybiMYMjLICpOBr22PiR7G cLj078D7b8Q9eigZMr4OZwHZ7ob2F4c87g== X-Received: by 2002:a50:a56d:: with SMTP id z42mr6430929edb.241.1561663119763; Thu, 27 Jun 2019 12:18:39 -0700 (PDT) Received: from archlinux-epyc ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id bs5sm575800ejb.10.2019.06.27.12.18.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 12:18:39 -0700 (PDT) Date: Thu, 27 Jun 2019 12:18:37 -0700 From: Nathan Chancellor To: Tyrel Datwyler , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman 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 Message-ID: <20190627191837.GA111331@archlinux-epyc> References: <20190603174323.48251-1-natechancellor@gmail.com> <20190603221157.58502-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603221157.58502-1-natechancellor@gmail.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Gentle ping, can someone pick this up? Cheers, Nathan