Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4654811ybi; Mon, 3 Jun 2019 14:54:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOwW8pJtYKWYfaMYSrerNYXD3QXLWu2qX3PLYHE+2lW5PyMsPt9FeJb+XxTVMsAjCbSHAR X-Received: by 2002:a17:90a:f488:: with SMTP id bx8mr33314619pjb.62.1559598869918; Mon, 03 Jun 2019 14:54:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559598869; cv=none; d=google.com; s=arc-20160816; b=GroiUIovVHuImIaR4xDiB6K2RdGt3UwerNBXHcdaOFU91l+jHFADi3fNEfBwDlARq0 UqZSqELW9vUpPdzSJlQIkJQzHR4l1y2ydtikHqzOaHU+NdxtxSOsyHO71X/+QnupId16 sEJSAMyG55NsJjeZePUsccqUmKnQDCDY65HuBco+K+7FCNLDu8bjpF9jEMWePDHKCTnd ae6uHOjV7SVfceUi2a4E4kb5cA0fK+zAnPjxJVzK1MgV+28gjniM3vZjxO8WzDxC4MYq AoY4O9EAVM8TbKmsGQdw6Vq7Cqhmuu/2q3LMkKVd9UdXI5cnRwrtuLxLe9QOibM8cp1s d/lQ== 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=spxbSxrpztoX+OYGfxSQU5fac10irlk+vBajDvb33D0=; b=GoTg6Re0LpO7Ia4VnsrtPYPQHx+JKqyhcmj5uJU5nqK9WcO+08uQ9Lo8RJ1UihsGjL nZA+wNlKVQzWc2C8W22iv3SI/JRAxmYU04W9SIBgkbDnC+aFdTAI9NtYsoAxYxI97/Ll H1ouYxOEcufCEm3E0jyINOrR4kYaJhay5fGHDWIGizV1+O3f8jaw0+fjMWiW8lgtrMrA 18Ek8Ln/jhvsg82JLvkbQO7sS1PAlBxRS0bc3WDEq0rut3sZJjeWmQkZ6iW+1QAqXqS2 bkao9RoM8JBC73fyhxPjr+8W4nsXxGyySFWjox590228gar3SmYHYGSf8Id3xGRoocCQ HYuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iADSXB00; 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 s97si20918851pjc.9.2019.06.03.14.54.14; Mon, 03 Jun 2019 14:54:29 -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=iADSXB00; 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 S1726710AbfFCVvm (ORCPT + 99 others); Mon, 3 Jun 2019 17:51:42 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:36554 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726305AbfFCVvl (ORCPT ); Mon, 3 Jun 2019 17:51:41 -0400 Received: by mail-ed1-f68.google.com with SMTP id a8so28925180edx.3; Mon, 03 Jun 2019 14:51: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=spxbSxrpztoX+OYGfxSQU5fac10irlk+vBajDvb33D0=; b=iADSXB000vxOYJWwJoRtrAYRSo/dfLvDu8/qH49kJalqjkE/hRmqwTCq4kjqxxqPyz mt7rwocjIZSBlcJTIetx5SRB82REH/WVNBhcl/al+3Jnif0mJk2tmzdtMRWUZ/A9kT+f +vZRpM+tuHCzspT7CZxurPYPB5NkolL3JSOI2GggioMDa08zdzPluWWVaVkHqoXiCkaF QXAllhgAKLE4rh2W5lCa5VoyCUhA+VrsRxjDVyYQz3WfPeUL4nfKX1Op/PRfZenluLnr CDCQdYjIMW3k8Zlz8Dump4vaQY8BmqE5+lU9xzFcikpVlzg1kzyo3c4a1Az/Y6tPhB4d Zt3A== 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=spxbSxrpztoX+OYGfxSQU5fac10irlk+vBajDvb33D0=; b=bmMdPMoIggss6hKIf/XCxx8jnOB8Mg7LfFjIqJSBRK0kdLZ06RgRrSnzVWW/d6kPBi moSZB/5UKGjFPAxAVUJwfA2R1m50qZGCXtz5hnDeewjwNCg8cvxcHILHvypno8YH+9o+ a1NwuL29iYB//b0uuunqu7xgOKyPks+UJcaroRcJzOttvEipAnzNOiVVNpFXfhl5E/3s Tsz0A46eaqkv8TMt66ebWhwd5+IXEZFqRsgbAQTpY+OX175ix55+gzdrUgiWmiL+Tn6L quAesuncAaaOoOru+5uFrG9GrIGXpuPqw0R/JQ60Y356CmoWAdLiry2OAxUZlNK8DXZ0 llng== X-Gm-Message-State: APjAAAVihVnRlXixCG/4EUqZS2P+mSezb7hHQ9c+e2DxUvkIR+511taQ cuHz4dd+d6vhN1SGBnYBNEc= X-Received: by 2002:a17:906:25c9:: with SMTP id n9mr4769934ejb.51.1559598700059; Mon, 03 Jun 2019 14:51:40 -0700 (PDT) Received: from archlinux-epyc ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id p13sm4239321edm.97.2019.06.03.14.51.38 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 03 Jun 2019 14:51:38 -0700 (PDT) Date: Mon, 3 Jun 2019 14:51:36 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Tyrel Datwyler , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Bjorn Helgaas , linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, LKML , clang-built-linux Subject: Re: [PATCH] PCI: rpaphp: Avoid a sometimes-uninitialized warning Message-ID: <20190603215136.GA45181@archlinux-epyc> References: <20190603174323.48251-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nick, On Mon, Jun 03, 2019 at 02:07:50PM -0700, Nick Desaulniers wrote: > On Mon, Jun 3, 2019 at 10:44 AM Nathan Chancellor > wrote: > > 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. > > Thanks for the patch Nathan. fndit isn't really being used for > anything other than a print statement outside of the loop. How about: Thank you for the review, this seems reasonable. I will send a v2 shortly. > > ``` > 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))) && > ``` > (not sure my tabs were pasted properly in the above...) Doesn't look like it but no worries. Thanks, Nathan