]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: lpfc: avoid uninitialized variable warning
authorArnd Bergmann <arnd@arndb.de>
Fri, 22 Mar 2019 14:25:49 +0000 (15:25 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 26 Mar 2019 02:17:26 +0000 (22:17 -0400)
commit027175d587b35c7272f7d04089191898f25407ae
treef0468e4fdfd572c5686311a5f8e837480fca9275
parent2dbb8c4275d82e28f89c3183d75c09c2d1f2c62f
scsi: lpfc: avoid uninitialized variable warning

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 <arnd@arndb.de>
Acked-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/lpfc/lpfc_nvme.c