mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: qla2xxx: Remove unnecessary call to memset
@ 2020-08-20 18:51 Alex Dewar
  2020-08-20 23:49 ` [PATCH v2] scsi: Don't call memset after dma_alloc_coherent() Alex Dewar
  2020-08-24 21:42 ` [PATCH] scsi: qla2xxx: Remove unnecessary call to memset Alex Dewar
  0 siblings, 2 replies; 10+ messages in thread
From: Alex Dewar @ 2020-08-20 18:51 UTC (permalink / raw)
  To: Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel
  Cc: Alex Dewar

In qla25xx_set_els_cmds_supported(), a call is made to
dma_alloc_coherent() followed by zeroing the memory with memset. This is
unnecessary as dma_alloc_coherent() already zeros memory. Remove.

Issue identified with Coccinelle.

Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
 drivers/scsi/qla2xxx/qla_mbx.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 226f1428d3e5..e00f604bbf7a 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -4925,8 +4925,6 @@ qla25xx_set_els_cmds_supported(scsi_qla_host_t *vha)
 		return QLA_MEMORY_ALLOC_FAILED;
 	}
 
-	memset(els_cmd_map, 0, ELS_CMD_MAP_SIZE);
-
 	/* List of Purex ELS */
 	cmd_opcode[0] = ELS_FPIN;
 	cmd_opcode[1] = ELS_RDP;
-- 
2.28.0


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH] scsi: qla2xxx: remove unnecessary call to memset
@ 2017-09-11 12:54 Himanshu Jha
  0 siblings, 0 replies; 10+ messages in thread
From: Himanshu Jha @ 2017-09-11 12:54 UTC (permalink / raw)
  To: martin.petersen
  Cc: jejb, qla2xxx-upstream, linux-scsi, linux-kernel, Himanshu Jha

call to memset to assign 0 value immediately after allocating
memory with kzalloc is unnecesaary as kzalloc allocates the memory
filled with 0 value.

Semantic patch used to resolve this issue:

@@
expression e,e2; constant c;
statement S;
@@

  e = kzalloc(e2, c);
  if(e == NULL) S
- memset(e, 0, e2);

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
 drivers/scsi/qla2xxx/qla_init.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index b5b48dd..54c1d63 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -7917,7 +7917,6 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
 			    "Failed to allocate memory for queue pair.\n");
 			return NULL;
 		}
-		memset(qpair, 0, sizeof(struct qla_qpair));
 
 		qpair->hw = vha->hw;
 		qpair->vha = vha;
-- 
2.7.4

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

end of thread, other threads:[~2020-09-03  1:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 18:51 [PATCH] scsi: qla2xxx: Remove unnecessary call to memset Alex Dewar
2020-08-20 23:49 ` [PATCH v2] scsi: Don't call memset after dma_alloc_coherent() Alex Dewar
2020-08-24 21:52   ` Alex Dewar
2020-09-02  1:22   ` Martin K. Petersen
2020-09-02 15:51     ` Alex Dewar
2020-09-02 16:03     ` Alex Dewar
2020-09-03  1:20       ` Martin K. Petersen
2020-08-24 21:42 ` [PATCH] scsi: qla2xxx: Remove unnecessary call to memset Alex Dewar
2020-08-26 16:34   ` Arun Easi
  -- strict thread matches above, loose matches on Subject: below --
2017-09-11 12:54 [PATCH] scsi: qla2xxx: remove " Himanshu Jha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®