Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6512256ybi; Sun, 21 Jul 2019 19:51:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxan4OSDv3Wdo6WDTPtC1gJKux4sJa/GPkdyhBIeoRKJa3nlB2kgbyF7++lqrD0np7Mo66k X-Received: by 2002:a17:902:5c3:: with SMTP id f61mr67731688plf.98.1563763918965; Sun, 21 Jul 2019 19:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563763918; cv=none; d=google.com; s=arc-20160816; b=M163d2WhVQW1GlxJhYjuzatCwcu2jBSsMsKQEFyFnuWyfS+o0DjiYbzltiu2FHcxDi EUuee2PBl8tlLVO+5+HNpA70gYSjsGva6UkrUOPAJm0IQL+in8AFbT/CSRGIo/VN5VCk Jz4yBKZKYCQhJnaf8gkEQHZJnfBFK+0MOGitms0VBWniggil5rOkEx6IYlaYsmdJ0wNG pGG2hmZWNvhXO8rNgrGtfV4BhiscmYEeyXDoweyezTiZmyoEcHBwe6HFdlNJat2YehOt F94hFO8eCeh7yNyo5AF9tq4SEwp7P4YXQZpLMcqqIwUCjqxQYHrWPnOsvKqCSACTxJ1h t4YQ== 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=aCIw0Vy9KSLKWPzknfpX/7qQ/M+ZYVeRzfb1AdszhK8=; b=TNtYOt+a1tmBNzefxVRNoN3YkEp2S6UFNv6zlz1rHFvYWxExvCtoEucQHIS2hLBQUH m80QhFWRrWMMUlEKpKoK2sJVwzT4wrXmPhBh3U1ZNKtVyY5T/cV1agNdEa+QqNClv1Sr LxROdK5l+9lR9Rhl7SkO5rmHJt6tZHziB5Iv+1L+x7DLpNa2h61qlQcsDZMCvR+n6URx 7Hru+R9iOeXnow/5zHhbQoxopsIKSPqo53N5MJqfuv0ayMhmv3ET+LrTrHB4srRdWg4O xrPVxatqEmE00yosaUtCJaB22rdk+RM5EUsYZs6vCTdzDI4db5FbSAqEHwq4kUbGb0fX 1BDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Xp2/lYdr"; 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 fr6si12401968pjb.97.2019.07.21.19.51.43; Sun, 21 Jul 2019 19:51:58 -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="Xp2/lYdr"; 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 S1728673AbfGVCnS (ORCPT + 99 others); Sun, 21 Jul 2019 22:43:18 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51782 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfGVCnS (ORCPT ); Sun, 21 Jul 2019 22:43:18 -0400 Received: by mail-wm1-f65.google.com with SMTP id 207so33596853wma.1; Sun, 21 Jul 2019 19:43:16 -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=aCIw0Vy9KSLKWPzknfpX/7qQ/M+ZYVeRzfb1AdszhK8=; b=Xp2/lYdri2nLJDOlJfb211oI7elKKCL7sv3olg1Vg53EBJdF8zXcHEjoMwEYKORhJ9 G9c8gBRAJkUBPoVtHDNKhod7PSDLP7q1j/bhEKpcIyM/Ll9TMeag8Uca/4SaXABE2358 4TCbeHhOFh6ClxCvpR2MKU0ecVGRHIqEKkMB3Wq/GD/B6+uwE/DWDyRWN6ccHegZXz+j /NcCtOj5uhCQyQ5e5tLRkBW1eMw+/BNrQ/JIDwdf3PdPOpOGYD4NU0piXolynZn/pF46 tYRysmQ6XKiEUN7JE/jCBX3vXMutKXEPrp8EGG2Pq8Yd32/uHs2DGGOoOqo7qwiqWbiR 3kOQ== 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=aCIw0Vy9KSLKWPzknfpX/7qQ/M+ZYVeRzfb1AdszhK8=; b=LSGhigIyXipIuYDNywnqN9g5zFkC5/UxZKEYwQ7KRIzq3SSic7gw6ntr5wqQXYtabD pMvnjHvLSuNXHgyi+m0AVglPglLDC2Z6Xj0g7IlSprbSLewfc4oueW7HuAurcTBofyFm HiPpRsJzun/r+yocr9kWSyJVQwJVUWwGNk6zhZqyy4lodpsDNlnWNqu+2g4JtVBdMb8c 2JqSdexdYSUiHiE79kSGtQbWpkT+5bPfy/rXkcnoI/K6KqF2dFWwBCWbh/vXLu9NAWqL ZLVb3sBL+YEKR0uGyCyWxJ4tOWlVhbMBRRGG2eZKk39vT/kE7O4bcB7vlH+qZAEszspR FsUw== X-Gm-Message-State: APjAAAV77oQchC69gIehnTQXO1lWOKWxEqpJPQ7MrbdQslmxg7GJsoIM 3cM9NrFHSDmfYL5509BOnqs= X-Received: by 2002:a7b:c0d0:: with SMTP id s16mr30063516wmh.141.1563763395957; Sun, 21 Jul 2019 19:43:15 -0700 (PDT) Received: from archlinux-threadripper ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id 91sm80347851wrp.3.2019.07.21.19.43.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 21 Jul 2019 19:43:15 -0700 (PDT) Date: Sun, 21 Jul 2019 19:43:13 -0700 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, Nick Desaulniers Subject: Re: [PATCH v2] PCI: rpaphp: Avoid a sometimes-uninitialized warning Message-ID: <20190722024313.GB55142@archlinux-threadripper> References: <20190603174323.48251-1-natechancellor@gmail.com> <20190603221157.58502-1-natechancellor@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603221157.58502-1-natechancellor@gmail.com> User-Agent: Mutt/1.12.1 (2019-06-15) 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(-) > > 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))) && > -- > 2.22.0.rc3 > Hi all, Could someone please pick this up? Thanks, Nathan