Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp732267img; Fri, 22 Mar 2019 07:27:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSJpoSxKjf93+W6uGdBcV1xMa6iOfiQmpErXrMuUoApGHNUjldBlnryOKIo3R7L1BOaeAV X-Received: by 2002:a63:3d01:: with SMTP id k1mr9089488pga.237.1553264874119; Fri, 22 Mar 2019 07:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553264874; cv=none; d=google.com; s=arc-20160816; b=ayUwSA16vJyVNy4SgaMXjc7g5yG2GL7LtDDj3Eo/Q0rCl+Mxyp40mw7Aoo/bLoQpXu b9RcfUsZKZlHHtvBl8PF54cIpGnF08zskYoosvIeGUEl8t6hAHCQDerBNfhmLZOiELDs TTLLs3epBOUeSByvn/fc43cAjB1bT3l0IqTsxHS3dBeHBTJgPQJuVvTUeUNftVa8nuU1 3KsqRHx/ckAubi14YPkKDmf07iYp/XZgYd85Ukt8KShWs8H51qz5RqM9qnj96q1waGBg mcPvVibvXv8gDIrSxWmp5/ks4SRC5j6+4oWmXsxmLvNelJXDp35yzJsgqedjVMpQ6can hOGw== 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; bh=cqNtrtCuz8k36Iv6q33sorIb5GR+wJgl8Is7ZLNin8U=; b=Zr7yz9c7m5VU9yBqHO03DCTEJwD8GUJy3T2mnMgCjgvW8lQse2n0sgGXwrqFQ3TFvj BdXvl5VHZUnnE0xR/Rrb0NnD6ajn8JyWE9ca7hnSiwiHnI4FSntFNP9cwuEchMEhRhWO uvWD3y1rojrxb61Pjioafbe8Co+AiqIkpRndZFI15/CzKp9yM2QYdS4GyRoe21J6fvvd x0E3MyU6EfEKLImS/9nRhClBoADT8JGqaQEZfYvz3sysaAZihq7DtyTjhPcPGbYPaAfy V+CrwMFRgLf7qvc/U5C6X/5T/8eVWt5XZOdaDbqA7l2lbxPO2t9wUtN+akNYapFgnaeR KmJg== ARC-Authentication-Results: i=1; mx.google.com; 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 h21si7023531plr.229.2019.03.22.07.27.36; Fri, 22 Mar 2019 07:27:54 -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; 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 S1728771AbfCVO0n (ORCPT + 99 others); Fri, 22 Mar 2019 10:26:43 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:51365 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728061AbfCVO0m (ORCPT ); Fri, 22 Mar 2019 10:26:42 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1McH1Q-1gZ7MZ0ZbA-00chgM; Fri, 22 Mar 2019 15:25:59 +0100 From: Arnd Bergmann To: James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Hannes Reinecke , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: lpfc: avoid uninitialized variable warning Date: Fri, 22 Mar 2019 15:25:49 +0100 Message-Id: <20190322142557.929966-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:PGU9lVKj/dKXmiqHlrV8Bly73FjLI9kdmgn+Cziu7tOV08Qy6Ev bxGqn4M0D7NkQhxZbGIBSOh3kb0D0dyd8ox1ZvRwR89OKiiodHUeod8pLCmGZ5ugw+AS7mz V0KLOHxiZo3so2lWDA6LsALzA6EdoVW0KETNKzrzI6Ag8MvfN18MF28KSZvJ4jeRGQuK4AJ TElZLVpn31dAeQKxdfTeA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:MVlH0d45pZk=:sI1gMV387Mc4/wy6tiGfV+ 5Gpgvlx5nuQLJmBewGdZNG8GTVNoPN/xleIqA0xs/IvmYq7ybEc0q8QokvFuCOS9Bls68sqjq 4KFavIKumrPyawteq/dJqgUnciiZcV6HdzMt1MaRcnHdyOo4XRtBFrpq5BxcFlykRiqg5vpTp kUDSLAIcSrDnMa9FkfWR77br0qdZdW2cetjFwKDFAVWo1H3jNp6iOxxXkIpTda1rY3DBcxk6h 5D96uuEKMC4KDP/X1Izld5kznIAYLFBFxcYwBBNh0coDXN/t1xLgcnzXideaFmvwY66ywffpZ bFzPWKUVHFMotUo/UAYeTeE2z6+HsxKP1hmatl8U3kTGMppJsCJz5RpXS+WVe0emGLzxUpMIV TKOTFYJxZrX8sNMzsxNk52neksdHcHaAD+a0j2uHof0jwvaje8Bt0n9MF53e2Ue9VFSEmKnpt iDNwEitR4bBs/+sKXMz6PqO3gunnVmemc6MjmVnyvO5/ZV8Fdw+skOzvdH2MMyNifecK2H349 pSrOiZIMw6mF3RRrZnsrONG+Gp3P8Jaml9rzlJwCLGhSdfvfjp9xu5awaEIUifiPUFHYOBBU2 UZ0StH9QjaU4lOKO55RdTZBWV9dCaE1mET2EMVMPFMKmZDR7N8B5mclJE1fQYM1sB36ZOkJYZ Ug00Wpc8WgUTKTuJyGPsm4Un04AJYhR4AssaxPaahdwVHy6iFCZGXG6ici0qhkCDtIfqiX4MB iAGzPk+zx3fFgcaEIYLhFdWIIut/FIddQduYhw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 " -- 2.20.0