Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3379219ybp; Sun, 6 Oct 2019 10:38:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwldBqsfiNONkWFTlp1W/TALvjO+YVRFmkh0SUmIbcUlLiODJC7r6/22/5MlfHy6MCa6mc X-Received: by 2002:a05:6402:1549:: with SMTP id p9mr25682692edx.221.1570383492302; Sun, 06 Oct 2019 10:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570383492; cv=none; d=google.com; s=arc-20160816; b=uAIxSiWZ//pybIAMe0FNzt2VTRnnnraO6KLYZAK+q9n7y3iddLV8XI4YViWWB1rLvm sykttP2Fa+MoUDq0qJsi/TQ9KoG7ik1LMaS3wmPD74MyeMaZZT7TQEQeyj4gSWFHhDbp 5Dn1TpFG+TuGj+FplQkTu/DmAM123WgukcrlW+Olljyzte47y0ukki1EVVxGrrdUQbGR i30uODavcxbvNRBsIgWD9AdDsott2AsCIwG/tD6k25h/sAc7S8V/3FZFMswq7JevORqR YaPyUGC0EPX2oTE1GhK1rTJ0wRwv+iVXtMzMkSOuPcxwtnR6/eIFYugzlJ2EX+PpRxwu lImA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h0fEiv0sp6cbGaaSvluO7JgNKxkUBB09hAimgYvZyW0=; b=j4KCBm7HZ+aPED1ROK4mtRWAZW7G+gTj1xq6KRh+5bLrxbgFWkUsB2I/IEOntf+XkC ufyx5BF5nNLomu3Id8B3GQ7O6B1C1Lk/p33g1qwOdJMEC2EQP4hicsp3hTxwzZMhbnXU RuFya4ANBvjzX49LFL+kooLemeJgV7PRKDeM2v7ikV3CjnbiU2IPthCXGffQ512qA9T+ hb130Q9OmT9UA7tbj138LknoTerf0xIKP0MeI47Nob7wjFLX3RIoQIUkgt186fr/d+EW 0JK4jh7r3HKmDapIGuigUmbOwpWzk7fXlHv9/6GZ3U6FImkcnfWogLvV/KK+cru5cUON h9nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qYWp2gcA; 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 d27si7875688ede.381.2019.10.06.10.37.48; Sun, 06 Oct 2019 10:38:12 -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=@kernel.org header.s=default header.b=qYWp2gcA; 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 S1730069AbfJFRgI (ORCPT + 99 others); Sun, 6 Oct 2019 13:36:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:34834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730056AbfJFRgG (ORCPT ); Sun, 6 Oct 2019 13:36:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BE0FC20700; Sun, 6 Oct 2019 17:36:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383365; bh=11lJkN1wtJ5AhK02O4kXnVotVpGg6k+q3v4S5ecZOKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qYWp2gcAkHbDF/8OH/+a0AkTieCUC8qlL4oOyXRfKtnLL0dZfHIu2jSCyxuIwfsu5 Nd18v9XviXlbW5PPUFYhtMrOx7hWZOH0OWGhD+xy3WQPjNIhBNrNjHbDc8oNNkBwsC aIJqp2eh1MLGuBDcp2W3UzXSq5QVeQhi1yyWhMD8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Desaulniers , Nathan Chancellor , Tyrel Datwyler , Joel Savitz , Michael Ellerman , Sasha Levin Subject: [PATCH 5.2 040/137] PCI: rpaphp: Avoid a sometimes-uninitialized warning Date: Sun, 6 Oct 2019 19:20:24 +0200 Message-Id: <20191006171212.356941548@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171209.403038733@linuxfoundation.org> References: <20191006171209.403038733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 0df3e42167caaf9f8c7b64de3da40a459979afe8 ] 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. Fixes: 2fcf3ae508c2 ("hotplug/drc-info: Add code to search ibm,drc-info property") Suggested-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Acked-by: Tyrel Datwyler Acked-by: Joel Savitz Signed-off-by: Michael Ellerman Link: https://github.com/ClangBuiltLinux/linux/issues/504 Link: https://lore.kernel.org/r/20190603221157.58502-1-natechancellor@gmail.com Signed-off-by: Sasha Levin --- 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 bcd5d357ca238..c3899ee1db995 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.20.1