scsi: lpfc: avoid uninitialized variable warning

This change “scsi: lpfc: avoid uninitialized variable warning” (commit faf5a74) in Linux kernel is authored by Arnd Bergmann <arnd [at]> on Fri Mar 22 15:25:49 2019 +0100.

Description of "scsi: lpfc: avoid uninitialized variable warning"

The change “scsi: lpfc: avoid uninitialized variable warning” introduces changes as follows.

scsi: lpfc: avoid uninitialized variable warning

clang -Wuninitialized incorrectly sees a variable being used without

drivers/scsi/lpfc/lpfc_nvme.c:2102:37: error: variable 'localport' is uninitialized when used here
                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 <>
Acked-by: James Smart <>
Signed-off-by: Martin K. Petersen <>

Linux kernel releases containing commit faf5a74

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "scsi: lpfc: avoid uninitialized variable warning"

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 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 08a013e704f2..b476394b5da9 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -2082,15 +2082,15 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport)
 		lpfc_nvme_template.max_hw_queues =
+		return ret;
 	/* localport is allocated from the stack, but the registration
 	 * call allocates heap memory as well as the private area.
 	ret = nvme_fc_register_localport(&nfcp_info, &lpfc_nvme_template,
 					 &vport->phba->pcidev->dev, &localport);
-	ret = -ENOMEM;
 	if (!ret) {
 		lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NVME_DISC,
 				 "6005 Successfully registered local "

The commit for this change in Linux stable tree is faf5a74 (patch).

Last modified: 2020/02/09