Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2787981ybd; Thu, 27 Jun 2019 19:58:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6QVDpamurwxBBPABN3t0tcjtYEwIU0LHyGlK4n+ZSC7BZV2HQKZpd6MsLUtmN+qBve8uH X-Received: by 2002:a17:902:404:: with SMTP id 4mr8733945ple.200.1561690736681; Thu, 27 Jun 2019 19:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561690736; cv=none; d=google.com; s=arc-20160816; b=g7IdRkK4LS3uJs89FnAaPqMgdvFebTPAvo+eXb09w7o9H8+QoYrRVNkVf9tyZL+bhH bv/BV9wk+iXd8P4NT1ztD6t7GdHKK9PHiBqVqYDFwDJZX7yKCf5MC/9kzn8O8ukFIVny M2LM2hBunO+djkNx/LYpvMB+Dy/HHKHkDsFXAyumN3bFG7N+B/4ToaYaSmJJTmdGXnwI xrpwk8uIyQ2xtVMIbb6hIO+frojEG/swKYjbKtf6nmRichJZ5Lpuiz4ECnav936akT7v MOKwQg7CAP0zybbKSWXnja8ubA2CMfX1XauJqI0yYO3qpkKiIBbdt2ZyAjzMEbxzTH08 5iiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:message-id:date:subject:cc:to :from; bh=aEIDSolzXh9ZJzQKruKmDBhpiacHar6IoYtrVlcKI4g=; b=RbZ+aILw5+kkRYO/Tv+3Yem1v4NkDEfdHP4tHbRObT+F9NDHbLCF4yD60Ei1DKLksD J7yxz+rNiLJ/QYFcLwtvkYyF8g3oUb4NSod3eIPc1HsYl680nAeKL0qCdGqqPPMENMjP SHju5E9eFgOlABGTRpPPG6GknKKdV6jZ8TJ8IKn7AmHkGSt1i9aS8GJ+zyloOCb6VO0g qFKPSLDHBFMDeu2BjTxHBSK8kv8fqELHwnNCfk5R+tN0wyYXLaweBs71xeoAHtcZlk0g AUcW22a96qpQ57Ydkt6wuOPvuPamUoCBpG4UuYe63ZXTY+k7fiLygrXEb2RDYGNpiqbu 0GLQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si856748pgq.416.2019.06.27.19.58.39; Thu, 27 Jun 2019 19:58:56 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726811AbfF1C6h (ORCPT + 99 others); Thu, 27 Jun 2019 22:58:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59398 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfF1C6g (ORCPT ); Thu, 27 Jun 2019 22:58:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B92A8356D4; Fri, 28 Jun 2019 02:58:33 +0000 (UTC) Received: from jsavitz.bos.com (ovpn-123-72.rdu2.redhat.com [10.10.123.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id B46BC60BE0; Fri, 28 Jun 2019 02:58:29 +0000 (UTC) From: Joel Savitz To: linux-kernel@vger.kernel.org Cc: Joel Savitz , Tyrel Datwyler , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Bjorn Helgaas , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, clang-built-linux@googlegroups.com, Nathan Chancellor , Nick Desaulniers Subject: Re: [PATCH v2] PCI: rpaphp: Avoid a sometimes-uninitialized warning Date: Thu, 27 Jun 2019 22:57:54 -0400 Message-Id: <1561690674-5880-1-git-send-email-jsavitz@redhat.com> In-Reply-To: <20190603221157.58502-1-natechancellor@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 28 Jun 2019 02:58:36 +0000 (UTC) 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(-) >> Gentle ping, can someone pick this up? Looks a good simplification of somewhat convoluted control flow. Acked-by: Joel Savitz