Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp847588img; Fri, 22 Mar 2019 09:48:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8lgOZOPkUiFdLg8yXBEuEEJSkCdndndVH9xRW43TkGXBXODihyqEvhNIlr1cL2aPE/kGI X-Received: by 2002:a17:902:b181:: with SMTP id s1mr10451632plr.321.1553273309785; Fri, 22 Mar 2019 09:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553273309; cv=none; d=google.com; s=arc-20160816; b=v/h9A0HiJqqpQFAWhsJD1A5+AS+5Rp72K1VVUBy49tpDCsBsnH7elZsHUoS6zFS/NR ahvKoCRoTvAiQSWFb7fNtlmHqeD8BKmKEeo9/zVzk+R+SCwx8oJ7fhse2sBHhSh+RHvH p1GmqmTnzOLp9qu23zsTzrKiXFZEVycpOqlG9NpqN0EgpJnNNBTaagyVuyXzZSxJwmYR SySPnTbcTpLy8lctXXJ+l8U+aLhD/nXUXWddhV/QAV5rf68ljgivlAec6niQ1ByPrBD8 dGQpYbx4zOhgdjvEj5TiiIXCa6JXCjLUq09KxsB0denQ0lI123fyrDk9p13w/JzIkdHP NxiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=K875wjAwkZl75zaoc/3T/DTeSTNRlQQDrBjQ2RVTMHY=; b=N6aGCv5ayjjhb2I91N+FZonLeWyOgInoWzGSVz8tnflNppG+WpRXrzYagyxfVEuEkk 6zAajqCIh66Uvv+dwVnASmYIGOHTSC/rbJHFnvti739OohhJ8QRISFYpoRwUIHD8PfD2 mh7NfffHnAx1RPDL3uKyxm1G9K4SLZ+xBMwLGLjFCRFQCr0tsWG+6eEte8yh+/Wl7rFq Jo+I0clF6DZu1QqhYCKz3rGc6lb3dvRVnxYH6/ZMSBVTIHPcfB5EjHfxX7KDnVAdbCpj es7BBB7CQIiOlRyqWA+GP19mCTRClt447KPwx+wD4m8B3JEJ1/adSgDPtE+XBj62XUbC aySw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=IHEZy86J; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f124si7139196pfb.38.2019.03.22.09.48.12; Fri, 22 Mar 2019 09:48: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=@broadcom.com header.s=google header.b=IHEZy86J; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727803AbfCVQrS (ORCPT + 99 others); Fri, 22 Mar 2019 12:47:18 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:43327 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727443AbfCVQrR (ORCPT ); Fri, 22 Mar 2019 12:47:17 -0400 Received: by mail-pf1-f193.google.com with SMTP id c8so1901862pfd.10 for ; Fri, 22 Mar 2019 09:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=K875wjAwkZl75zaoc/3T/DTeSTNRlQQDrBjQ2RVTMHY=; b=IHEZy86JyvZfceNIg+Bu7ywr3COVzubuLbQb6Lo1sOkexzBbs4Ayb7FXxyC1CvG+je gf/C8iBxD/COjeLM338gLvkUyZWB8w1LQHfqrlO1FDOKb/rru1dgDiGxDQOnkeJok6JK vhGOdF8n2CNfKbax+c6rDvIvbIfPr4w7Z/ZKU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=K875wjAwkZl75zaoc/3T/DTeSTNRlQQDrBjQ2RVTMHY=; b=B1WzaPPLNj0ygJUgaOMyoB2sILvteZk6Z2LYzJ2ZjIU2H1aTrqjtNQAAY2dWIin8jI Kxkw0ffja9wY50xtHJsf0Bw5eX9TmXZoIFnrTDNzLC+VjWlIkvBFJnFnCy0UGQVpWkyX NrYNbz/tGUWaugJy8RdOvM7lVNWAuhGT5AOa8p8A4uGKWXt7kyku/f57u6gyd4LM59QR EN73u9t/KlZAs2TAsZsSkMCIsyfiwejq3iDjRZeHo1hZS6HUkLV9ICbtSuQkQtbpos0X NF3/7Z1jkgo8HTytfk6YXt3YDYKSXY4NDV+H1yo5QPC0JyXngzrkcKCJIBxT73aVT+lV rn2Q== X-Gm-Message-State: APjAAAXKoR0faV/FKekFmx/yuKI9Mr8k0KWXidMBV+2d8mCDJSURxnhI 40RNmcZnBCzfRJEYal+I2L+0FaS+QDjdUGWKJRPeNWh+3dMwaAHV0ym61CzT8R+/8PEgo4MPCWR SDDeECfpRYoxkIVBHJTobipUqG00tz6WPuYm+eyxw9RCW48lcJF4d2GXYJ8BCnXCU/sH3G1RUlh o4dxY= X-Received: by 2002:a63:d542:: with SMTP id v2mr9984635pgi.52.1553273236324; Fri, 22 Mar 2019 09:47:16 -0700 (PDT) Received: from [10.69.37.149] ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id d3sm10921579pfc.125.2019.03.22.09.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 09:47:15 -0700 (PDT) Subject: Re: [PATCH] scsi: lpfc: avoid uninitialized variable warning To: Arnd Bergmann , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Hannes Reinecke , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190322142557.929966-1-arnd@arndb.de> From: James Smart Message-ID: <1a302ccb-2f9d-560d-8b07-eb5382684b76@broadcom.com> Date: Fri, 22 Mar 2019 09:47:14 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: <20190322142557.929966-1-arnd@arndb.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/22/2019 7:25 AM, Arnd Bergmann wrote: > clang -Wuninitialized incorrectly sees a variable being used without > initialization: > > drivers/scsi/lpfc/lpfc_nvme.c:2102:37: error: variable 'localport' is uninitialized when used here > [-Werror,-Wuninitialized] > lport = (struct lpfc_nvme_lport *)localport->private; > ^~~~~~~~~ > drivers/scsi/lpfc/lpfc_nvme.c:2059:38: note: initialize the variable 'localport' to silence this warning > struct nvme_fc_local_port *localport; > ^ > = NULL > 1 error generated. > > This is clearly in dead code, as the condition leading up to it is > always false when CONFIG_NVME_FC is disabled, and the variable > is always initialized when nvme_fc_register_localport() got > called successfully. > > Change the preprocessor conditional to the equivalent C construct, > which makes the code more readable and gets rid of the warning. > > Signed-off-by: Arnd Bergmann > --- > drivers/scsi/lpfc/lpfc_nvme.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c > index 1aa00d2c3f74..9defff711884 100644 > --- a/drivers/scsi/lpfc/lpfc_nvme.c > +++ b/drivers/scsi/lpfc/lpfc_nvme.c > @@ -2080,15 +2080,15 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport) > lpfc_nvme_template.max_hw_queues = > phba->sli4_hba.num_present_cpu; > > + if (!IS_ENABLED(CONFIG_NVME_FC)) > + return ret; > + > /* localport is allocated from the stack, but the registration > * call allocates heap memory as well as the private area. > */ > -#if (IS_ENABLED(CONFIG_NVME_FC)) > + > ret = nvme_fc_register_localport(&nfcp_info, &lpfc_nvme_template, > &vport->phba->pcidev->dev, &localport); > -#else > - ret = -ENOMEM; > -#endif > if (!ret) { > lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NVME_DISC, > "6005 Successfully registered local " Looks good Reviewed-By: James Smart -- james