linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io
@ 2022-03-18 14:52 Wan Jiabing
  2022-04-30  6:29 ` Christophe JAILLET
  2022-05-03  0:51 ` Martin K. Petersen
  0 siblings, 2 replies; 5+ messages in thread
From: Wan Jiabing @ 2022-03-18 14:52 UTC (permalink / raw)
  To: James Smart, Ram Vegesna, James E.J. Bottomley,
	Martin K. Petersen, Wan Jiabing, Daniel Wagner, linux-scsi,
	target-devel, linux-kernel

io->sgl is allocated by kzalloc(). The memory is set to zero.
It is unnecessary to call memset again.

Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
---
 drivers/scsi/elx/efct/efct_io.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c
index c3247b951a76..c612f0a48839 100644
--- a/drivers/scsi/elx/efct/efct_io.c
+++ b/drivers/scsi/elx/efct/efct_io.c
@@ -62,7 +62,6 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl)
 			return NULL;
 		}
 
-		memset(io->sgl, 0, sizeof(*io->sgl) * num_sgl);
 		io->sgl_allocated = num_sgl;
 		io->sgl_count = 0;
 
-- 
2.35.1


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

* Re: [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io
  2022-03-18 14:52 [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io Wan Jiabing
@ 2022-04-30  6:29 ` Christophe JAILLET
  2022-04-30  7:48   ` Finn Thain
  2022-05-03  0:51 ` Martin K. Petersen
  1 sibling, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2022-04-30  6:29 UTC (permalink / raw)
  To: Wan Jiabing, James Smart, Ram Vegesna, James E.J. Bottomley,
	Martin K. Petersen, Daniel Wagner, linux-scsi, target-devel,
	linux-kernel

Le 18/03/2022 à 15:52, Wan Jiabing a écrit :
> io->sgl is allocated by kzalloc(). The memory is set to zero.
> It is unnecessary to call memset again.
> 

Hi,

Nitpick: this kzalloc() should be a kcalloc() to avoid an open-coded 
multiplication when computing the size to allocate.

CJ


> Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> ---
>   drivers/scsi/elx/efct/efct_io.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c
> index c3247b951a76..c612f0a48839 100644
> --- a/drivers/scsi/elx/efct/efct_io.c
> +++ b/drivers/scsi/elx/efct/efct_io.c
> @@ -62,7 +62,6 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl)
>   			return NULL;
>   		}
>   
> -		memset(io->sgl, 0, sizeof(*io->sgl) * num_sgl);
>   		io->sgl_allocated = num_sgl;
>   		io->sgl_count = 0;
>   


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

* Re: [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io
  2022-04-30  6:29 ` Christophe JAILLET
@ 2022-04-30  7:48   ` Finn Thain
  2022-04-30  9:06     ` Christophe JAILLET
  0 siblings, 1 reply; 5+ messages in thread
From: Finn Thain @ 2022-04-30  7:48 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Wan Jiabing, James Smart, Ram Vegesna, James E.J. Bottomley,
	Martin K. Petersen, Daniel Wagner, linux-scsi, target-devel,
	linux-kernel, cocci

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

On Sat, 30 Apr 2022, Christophe JAILLET wrote:

> Le 18/03/2022 à 15:52, Wan Jiabing a écrit :
> > io->sgl is allocated by kzalloc(). The memory is set to zero.
> > It is unnecessary to call memset again.
> > 
> 
> Hi,
> 
> Nitpick: this kzalloc() should be a kcalloc() to avoid an open-coded
> multiplication when computing the size to allocate.
> 

Seems like kcalloc() conversion could be a separate patch. Perhaps it 
could be done everywhere using a coccinelle script.

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

* Re: [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io
  2022-04-30  7:48   ` Finn Thain
@ 2022-04-30  9:06     ` Christophe JAILLET
  0 siblings, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2022-04-30  9:06 UTC (permalink / raw)
  To: Finn Thain, Wan Jiabing
  Cc: James Smart, Ram Vegesna, James E.J. Bottomley,
	Martin K. Petersen, Daniel Wagner, linux-scsi, target-devel,
	linux-kernel, cocci

Le 30/04/2022 à 09:48, Finn Thain a écrit :
> On Sat, 30 Apr 2022, Christophe JAILLET wrote:
> 
>> Le 18/03/2022 à 15:52, Wan Jiabing a écrit :
>>> io->sgl is allocated by kzalloc(). The memory is set to zero.
>>> It is unnecessary to call memset again.
>>>
>>
>> Hi,
>>
>> Nitpick: this kzalloc() should be a kcalloc() to avoid an open-coded
>> multiplication when computing the size to allocate.
>>
> 
> Seems like kcalloc() conversion could be a separate patch. Perhaps it
> could be done everywhere using a coccinelle script.

Sure it can and I guess that many coccinelle script already exist for it.

I only replied here because of a comment from Joe Perches on the same 
patch a few month ago (see [1] and [2])

So Wan Jiabing or anyone else, if you want to go one step further, just 
feel free to propose it.

CJ


[1]: 
https://lore.kernel.org/all/4208b3d08a677601c73889f78dd25e5c9f056a86.camel@perches.com/

[2]: 
https://lore.kernel.org/all/9be7d5beb437583f8d975d168ac5c3e32fb6e465.1639158677.git.christophe.jaillet@wanadoo.fr/

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

* Re: [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io
  2022-03-18 14:52 [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io Wan Jiabing
  2022-04-30  6:29 ` Christophe JAILLET
@ 2022-05-03  0:51 ` Martin K. Petersen
  1 sibling, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2022-05-03  0:51 UTC (permalink / raw)
  To: James E.J. Bottomley, Wan Jiabing, Ram Vegesna, linux-kernel,
	James Smart, target-devel, Daniel Wagner, linux-scsi
  Cc: Martin K . Petersen

On Fri, 18 Mar 2022 22:52:20 +0800, Wan Jiabing wrote:

> io->sgl is allocated by kzalloc(). The memory is set to zero.
> It is unnecessary to call memset again.
> 
> 

Applied to 5.19/scsi-queue, thanks!

[1/1] scsi: elx: efct: remove unnecessary memset in efct_io
      https://git.kernel.org/mkp/scsi/c/507bd398a056

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2022-05-05  4:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18 14:52 [PATCH] scsi: elx: efct: remove unnecessary memset in efct_io Wan Jiabing
2022-04-30  6:29 ` Christophe JAILLET
2022-04-30  7:48   ` Finn Thain
2022-04-30  9:06     ` Christophe JAILLET
2022-05-03  0:51 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).