Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4443320ybi; Mon, 3 Jun 2019 10:57:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1/rHFwJX844x0Uy/563QN2Djb/p9+ZzFd+k/vIoaEJV4IdPTMSQcqCBhftQIW5TV8Huhg X-Received: by 2002:a63:9548:: with SMTP id t8mr29951226pgn.256.1559584625179; Mon, 03 Jun 2019 10:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559584625; cv=none; d=google.com; s=arc-20160816; b=aN/qOQJyAz34jqiu03tGbQRotek5GF2qj7xcIDSmz/6N2IwyfZwTbLrXUQI5vBC22P lwITCdwlMWw8IKSlXe64UUGfsn/Mbmi2qfM1dvAeY0bcb64zuhbjvdYXhZ24sM9Looq8 kLmV9p+OxiziIjd0n1k/o8KyYbgV98AhcCesMDMd+vE/lEv2MCBkI6IH0rqV4ahg440F HKLD7EB9DBayLDpkxNV7iQlwAb7C3UwanCHJOFK1/WmgW+wvPQz3re9BmoY5Rb+8pBEE ZMB6JrNJqqr2Imr6QuDgG2Ct4bD5U3HK0tF518GVlP6dULPg/9lEDV9hV619RBW02bkc Y1vQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UvPJ0pMiZoixpn1vorRDAMa+r0PwCmpA/CAl7+RUBFU=; b=ElT+F2IuC/Ca7tQxyxppkNCraV/mcmENdS4jGyTsFxXWiEZIKyk2+2DTrpaDimeD0E XyY9xM+EQLSWverCXotQE7EdT1L93WzkLVoJZXmVbrN+sCvreLR/p7pSeOYjv7nJRtZO v6Gra1st6+qQN0nG2QVxwNhugLbW/viZ9MCpZ/qeHw3S7Ti/5ZQ5GhqVFAkCU7l+F6xr jEr0C2TK5Lrz247X+9E9suilpU+7myRhJy1K/9NynfQmjOuliXfUp0h5J2VIGXdZ3lHI 7XrKweZwzMtJQCKg/Qe+lFl+IHbWxaPtES7hjTKK5Xxi57TPchCtG9k5rNmJTEnw5eEl cUfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mDpQCM0t; 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 b14si19974237pgk.423.2019.06.03.10.56.48; Mon, 03 Jun 2019 10:57:05 -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=mDpQCM0t; 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 S1728907AbfFCRo4 (ORCPT + 99 others); Mon, 3 Jun 2019 13:44:56 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:35688 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727415AbfFCRo4 (ORCPT ); Mon, 3 Jun 2019 13:44:56 -0400 Received: by mail-ed1-f66.google.com with SMTP id p26so28067198edr.2; Mon, 03 Jun 2019 10:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UvPJ0pMiZoixpn1vorRDAMa+r0PwCmpA/CAl7+RUBFU=; b=mDpQCM0tAqeODReAP8OTV9DQoxN3yLTrbJtlUsVjnmtI/1iuLx7p9FbWDiC0DYh6UQ Y0jCK+ksupdzG1tNrJR5ovgGWsKJ78pddBKDrQ33b4nE4T0Iw58uPk+joii9Zs8Fj7tA UFLSIUl8IF4g9SukjZM3OHserAnn95viimi3WLCbD1Q2sx2tghWyqFQFfOWOgCLR8sk+ J5e7xvriKldbYic86yWsDLSX8O+We57jRa9t30ZRAN79w2hxdd3Ts2NDWXdaC3si33zD +fd75c1OaYBe1maShaI11cbdIvM7wrX0TRoEYAXqBQW2Aw1PvXbI2y4M5QySroTMvWmp 33ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=UvPJ0pMiZoixpn1vorRDAMa+r0PwCmpA/CAl7+RUBFU=; b=PlKiAmyiO6SsAOsF5rBhpNK4Vs8z0G17c9q8bXuHJd40+bZ3wIaYYo/zPNOlR9W8FU XYtHulO6wuLWaGCwkwSzf9qhnqi9AEIyEN7+Q3tzTV3h5h6DL+2LV38+trBIKHsa6ftq giuu2vagx4GJ/D1RkTY2afiH7Pe6tU2peLszlLOKl9eLd06y3ZNVo40JHWsUiiNVEUsi LGGyxmRvJJSKpClBPqXNMAyG1+iet9xjbCVGmltcrfpF/GYQzI/nqYEmNppHgp9Qh8Ej E6+0epcthni28ZptPQWF65kPm3yE5CldIQ4un3XTmWAGk5x5g1ttiGmeEr79NZziqoLG Vmdg== X-Gm-Message-State: APjAAAWvYj7csnULFpNEM/eSFo8gSWgGgIjoie4aZYb4Sl8DK4k7gOJz mQ9PxNW8/Iw2ndQQxB0Gk2s= X-Received: by 2002:a17:906:951:: with SMTP id j17mr23314130ejd.174.1559583894230; Mon, 03 Jun 2019 10:44:54 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id i31sm266996edd.90.2019.06.03.10.44.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 10:44:53 -0700 (PDT) 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, Nathan Chancellor Subject: [PATCH] PCI: rpaphp: Avoid a sometimes-uninitialized warning Date: Mon, 3 Jun 2019 10:43:23 -0700 Message-Id: <20190603174323.48251-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.22.0.rc2 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Looking at the loop in a vacuum as clang would, fndit could be uninitialized if entries was ever zero or the if statement was always true within the loop. Regardless of whether or not this warning is a problem in practice, "found" variables should always be initialized to false so that there is no possibility of undefined behavior. Link: https://github.com/ClangBuiltLinux/linux/issues/504 Fixes: 2fcf3ae508c2 ("hotplug/drc-info: Add code to search ibm,drc-info property") Signed-off-by: Nathan Chancellor --- drivers/pci/hotplug/rpaphp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index bcd5d357ca23..07b56bf2886f 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, fndit = 0; info = of_find_property(dn->parent, "ibm,drc-info", NULL); if (info == NULL) -- 2.22.0.rc2