From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 247C8C4321A for ; Fri, 28 Jun 2019 04:05:20 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5940D2070D for ; Fri, 28 Jun 2019 04:05:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5940D2070D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45Zjpj0xkLzDqld for ; Fri, 28 Jun 2019 14:05:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=redhat.com (client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=jsavitz@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45ZhKt3pzpzDqbv for ; Fri, 28 Jun 2019 12:58:38 +1000 (AEST) 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 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) X-Mailman-Approved-At: Fri, 28 Jun 2019 14:03:42 +1000 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tyrel Datwyler , Nick Desaulniers , linux-pci@vger.kernel.org, clang-built-linux@googlegroups.com, Paul Mackerras , Bjorn Helgaas , Nathan Chancellor , linuxppc-dev@lists.ozlabs.org, Joel Savitz Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" >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