All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: lpfc: avoid an unused function warning
@ 2017-08-24 23:09 Arnd Bergmann
  2017-08-24 23:10 ` [PATCH v3 2/2] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
  2017-08-25 22:27 ` [PATCH 1/2] scsi: lpfc: avoid an unused function warning Martin K. Petersen
  0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2017-08-24 23:09 UTC (permalink / raw)
  To: James Smart, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen
  Cc: Arnd Bergmann, Hannes Reinecke, Johannes Thumshirn, Dan Carpenter,
	linux-scsi, linux-kernel

The only reference to lpfc_nvmet_replenish_context() is inside of
an #ifdef, leading to a harmless warning when CONFIG_NVME_TARGET_FC
is disabled:

drivers/scsi/lpfc/lpfc_nvmet.c:1457:1: error: 'lpfc_nvmet_replenish_context' defined but not used [-Werror=unused-function]

This replaces the preprocessor conditional with a C condition,
so the compiler can see that the function is intentionally unused.

Fixes: 9a38e4f1c82f ("scsi: lpfc: Fix MRQ > 1 context list handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/lpfc/lpfc_nvmet.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c
index 48a1c0c27a3f..0b7c1a49e203 100644
--- a/drivers/scsi/lpfc/lpfc_nvmet.c
+++ b/drivers/scsi/lpfc/lpfc_nvmet.c
@@ -1527,7 +1527,6 @@ lpfc_nvmet_unsol_fcp_buffer(struct lpfc_hba *phba,
 			    struct rqb_dmabuf *nvmebuf,
 			    uint64_t isr_timestamp)
 {
-#if (IS_ENABLED(CONFIG_NVME_TARGET_FC))
 	struct lpfc_nvmet_rcv_ctx *ctxp;
 	struct lpfc_nvmet_tgtport *tgtp;
 	struct fc_frame_header *fc_hdr;
@@ -1541,6 +1540,9 @@ lpfc_nvmet_unsol_fcp_buffer(struct lpfc_hba *phba,
 	uint32_t id;
 #endif
 
+	if (!IS_ENABLED(CONFIG_NVME_TARGET_FC))
+		return;
+
 	ctx_buf = NULL;
 	if (!nvmebuf || !phba->targetport) {
 		lpfc_printf_log(phba, KERN_ERR, LOG_NVME_IOERR,
@@ -1695,7 +1697,6 @@ lpfc_nvmet_unsol_fcp_buffer(struct lpfc_hba *phba,
 
 	if (nvmebuf)
 		lpfc_rq_buf_free(phba, &nvmebuf->hbuf); /* repost */
-#endif
 }
 
 /**
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] scsi: lpfc: avoid false-positive gcc-8 warning
  2017-08-24 23:09 [PATCH 1/2] scsi: lpfc: avoid an unused function warning Arnd Bergmann
@ 2017-08-24 23:10 ` Arnd Bergmann
  2017-08-25 22:27   ` Martin K. Petersen
  2017-08-25 22:27 ` [PATCH 1/2] scsi: lpfc: avoid an unused function warning Martin K. Petersen
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-08-24 23:10 UTC (permalink / raw)
  To: James Smart, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen
  Cc: Arnd Bergmann, Hannes Reinecke, Johannes Thumshirn, linux-scsi,
	linux-kernel

This is an interesting regression with gcc-8, showing a harmless
warning for correct code:

In file included from include/linux/kernel.h:13:0,
                 ...
                 from drivers/scsi/lpfc/lpfc_debugfs.c:23:
include/linux/printk.h:301:2: error: 'eq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
  ^~~~~~
In file included from drivers/scsi/lpfc/lpfc_debugfs.c:58:0:
drivers/scsi/lpfc/lpfc_debugfs.h:451:31: note: 'eq' was declared here

I managed to reduce the warning into a small test case for
gcc-8 that I reported in the gcc bugzilla[1].

As a workaround, this changes the logic to move the two assignments
of 'eq' out of the conditions and instead make the index conditional.
This works for all configurations I tried and avoids adding a bogus
initialization.

Acked-by: James Smart <james.smart@broadcom.com>
Link: [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81958
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/lpfc/lpfc_debugfs.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.h b/drivers/scsi/lpfc/lpfc_debugfs.h
index 7b7d314af0e0..c4edd87bfc65 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.h
+++ b/drivers/scsi/lpfc/lpfc_debugfs.h
@@ -478,16 +478,16 @@ lpfc_debug_dump_cq(struct lpfc_hba *phba, int qtype, int wqidx)
 		return;
 
 	for (eqidx = 0; eqidx < phba->io_channel_irqs; eqidx++) {
-		eq = phba->sli4_hba.hba_eq[eqidx];
-		if (cq->assoc_qid == eq->queue_id)
+		if (cq->assoc_qid == phba->sli4_hba.hba_eq[eqidx]->queue_id)
 			break;
 	}
 	if (eqidx == phba->io_channel_irqs) {
 		pr_err("Couldn't find EQ for CQ. Using EQ[0]\n");
 		eqidx = 0;
-		eq = phba->sli4_hba.hba_eq[0];
 	}
 
+	eq = phba->sli4_hba.hba_eq[eqidx];
+
 	if (qtype == DUMP_FCP || qtype == DUMP_NVME)
 		pr_err("%s CQ: WQ[Idx:%d|Qid%d]->CQ[Idx%d|Qid%d]"
 			"->EQ[Idx:%d|Qid:%d]:\n",
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] scsi: lpfc: avoid an unused function warning
  2017-08-24 23:09 [PATCH 1/2] scsi: lpfc: avoid an unused function warning Arnd Bergmann
  2017-08-24 23:10 ` [PATCH v3 2/2] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
@ 2017-08-25 22:27 ` Martin K. Petersen
  1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-08-25 22:27 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James Smart, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen, Hannes Reinecke, Johannes Thumshirn,
	Dan Carpenter, linux-scsi, linux-kernel


Arnd,

> The only reference to lpfc_nvmet_replenish_context() is inside of an
> #ifdef, leading to a harmless warning when CONFIG_NVME_TARGET_FC is
> disabled:

Applied to 4.14/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 2/2] scsi: lpfc: avoid false-positive gcc-8 warning
  2017-08-24 23:10 ` [PATCH v3 2/2] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
@ 2017-08-25 22:27   ` Martin K. Petersen
  0 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2017-08-25 22:27 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James Smart, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen, Hannes Reinecke, Johannes Thumshirn,
	linux-scsi, linux-kernel


Arnd,

> This is an interesting regression with gcc-8, showing a harmless
> warning for correct code:

Applied to 4.14/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-25 22:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24 23:09 [PATCH 1/2] scsi: lpfc: avoid an unused function warning Arnd Bergmann
2017-08-24 23:10 ` [PATCH v3 2/2] scsi: lpfc: avoid false-positive gcc-8 warning Arnd Bergmann
2017-08-25 22:27   ` Martin K. Petersen
2017-08-25 22:27 ` [PATCH 1/2] scsi: lpfc: avoid an unused function warning Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.