All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: qedf: Drop unnecessary NULL checks after container_of
@ 2021-05-10  4:12 Guenter Roeck
  2021-05-15  2:42 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2021-05-10  4:12 UTC (permalink / raw)
  To: Saurav Kashyap
  Cc: Javed Hasan, GR-QLogic-Storage-Upstream, James E . J . Bottomley,
	Martin K . Petersen, linux-scsi, linux-kernel, Guenter Roeck

The result of container_of() operations is never NULL unless the embedded
element is the first element of the structure, which is not the case here.
The NULL checks are therefore unnecessary and misleading. Remove them.

The changes in this patch were made automatically using the following
Coccinelle script.

@@
type t;
identifier v;
statement s;
@@

<+...
(
  t v = container_of(...);
|
  v = container_of(...);
)
  ...
  when != v
- if (\( !v \| v == NULL \) ) s
...+>

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/scsi/qedf/qedf_io.c   | 5 -----
 drivers/scsi/qedf/qedf_main.c | 4 ----
 2 files changed, 9 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 4869ef813dc4..6184bc485811 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -23,11 +23,6 @@ static void qedf_cmd_timeout(struct work_struct *work)
 	struct qedf_ctx *qedf;
 	struct qedf_rport *fcport;
 
-	if (io_req == NULL) {
-		QEDF_INFO(NULL, QEDF_LOG_IO, "io_req is NULL.\n");
-		return;
-	}
-
 	fcport = io_req->fcport;
 	if (io_req->fcport == NULL) {
 		QEDF_INFO(NULL, QEDF_LOG_IO,  "fcport is NULL.\n");
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 69f7784233f9..9c7efdf40dd5 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3971,10 +3971,6 @@ void qedf_stag_change_work(struct work_struct *work)
 	struct qedf_ctx *qedf =
 	    container_of(work, struct qedf_ctx, stag_work.work);
 
-	if (!qedf) {
-		QEDF_ERR(NULL, "qedf is NULL");
-		return;
-	}
 	QEDF_ERR(&qedf->dbg_ctx, "Performing software context reset.\n");
 	qedf_ctx_soft_reset(qedf->lport);
 }
-- 
2.25.1


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

* Re: [PATCH] scsi: qedf: Drop unnecessary NULL checks after container_of
  2021-05-10  4:12 [PATCH] scsi: qedf: Drop unnecessary NULL checks after container_of Guenter Roeck
@ 2021-05-15  2:42 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-05-15  2:42 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Saurav Kashyap, Javed Hasan, GR-QLogic-Storage-Upstream,
	James E . J . Bottomley, Martin K . Petersen, linux-scsi,
	linux-kernel


Guenter,

> The result of container_of() operations is never NULL unless the
> embedded element is the first element of the structure, which is not
> the case here.  The NULL checks are therefore unnecessary and
> misleading. Remove them.

Applied to 5.14/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2021-05-15  2:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10  4:12 [PATCH] scsi: qedf: Drop unnecessary NULL checks after container_of Guenter Roeck
2021-05-15  2:42 ` 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.