* [PATCH] scsi: elx: efct: Avoid a useless memset
@ 2021-12-09 21:51 Christophe JAILLET
2021-12-09 21:57 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2021-12-09 21:51 UTC (permalink / raw)
To: james.smart, ram.vegesna, jejb, martin.petersen, hare, dwagner
Cc: linux-scsi, target-devel, linux-kernel, kernel-janitors,
Christophe JAILLET
'io->sgl' is kzalloced just a few lines above. There is no need to memset
it another time.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
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 71e21655916a..e483d936342b 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.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: elx: efct: Avoid a useless memset
2021-12-09 21:51 [PATCH] scsi: elx: efct: Avoid a useless memset Christophe JAILLET
@ 2021-12-09 21:57 ` Joe Perches
2021-12-09 22:19 ` Christophe JAILLET
0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2021-12-09 21:57 UTC (permalink / raw)
To: Christophe JAILLET, james.smart, ram.vegesna, jejb,
martin.petersen, hare, dwagner
Cc: linux-scsi, target-devel, linux-kernel, kernel-janitors
On Thu, 2021-12-09 at 22:51 +0100, Christophe JAILLET wrote:
> 'io->sgl' is kzalloced just a few lines above. There is no need to memset
> it another time.
Better to use kcalloc as well and delete the memset
> diff --git 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;
>
---
drivers/scsi/elx/efct/efct_io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c
index 71e21655916a9..109483f3e3dfd 100644
--- a/drivers/scsi/elx/efct/efct_io.c
+++ b/drivers/scsi/elx/efct/efct_io.c
@@ -56,13 +56,12 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl)
}
/* Allocate SGL */
- io->sgl = kzalloc(sizeof(*io->sgl) * num_sgl, GFP_KERNEL);
+ io->sgl = kcalloc(num_sgl, sizeof(*io->sgl), GFP_KERNEL);
if (!io->sgl) {
efct_io_pool_free(io_pool);
return NULL;
}
- memset(io->sgl, 0, sizeof(*io->sgl) * num_sgl);
io->sgl_allocated = num_sgl;
io->sgl_count = 0;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] scsi: elx: efct: Avoid a useless memset
2021-12-09 21:57 ` Joe Perches
@ 2021-12-09 22:19 ` Christophe JAILLET
2021-12-09 22:29 ` Joe Perches
0 siblings, 1 reply; 4+ messages in thread
From: Christophe JAILLET @ 2021-12-09 22:19 UTC (permalink / raw)
To: Joe Perches, james.smart, ram.vegesna, jejb, martin.petersen,
hare, dwagner
Cc: linux-scsi, target-devel, linux-kernel, kernel-janitors
Le 09/12/2021 à 22:57, Joe Perches a écrit :
> On Thu, 2021-12-09 at 22:51 +0100, Christophe JAILLET wrote:
>> 'io->sgl' is kzalloced just a few lines above. There is no need to memset
>> it another time.
>
> Better to use kcalloc as well and delete the memset
Sure, thanks for spotting it Joe.
Should a clean v2 be sent or the patch in your reply is enough?
As your proposal is better than mine, if a v2 is needed, can you do it?
CJ
>
>> diff --git 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;
>>
>
> ---
> drivers/scsi/elx/efct/efct_io.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c
> index 71e21655916a9..109483f3e3dfd 100644
> --- a/drivers/scsi/elx/efct/efct_io.c
> +++ b/drivers/scsi/elx/efct/efct_io.c
> @@ -56,13 +56,12 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl)
> }
>
> /* Allocate SGL */
> - io->sgl = kzalloc(sizeof(*io->sgl) * num_sgl, GFP_KERNEL);
> + io->sgl = kcalloc(num_sgl, sizeof(*io->sgl), GFP_KERNEL);
> if (!io->sgl) {
> efct_io_pool_free(io_pool);
> 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] 4+ messages in thread
* Re: [PATCH] scsi: elx: efct: Avoid a useless memset
2021-12-09 22:19 ` Christophe JAILLET
@ 2021-12-09 22:29 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2021-12-09 22:29 UTC (permalink / raw)
To: Christophe JAILLET, james.smart, ram.vegesna, jejb,
martin.petersen, hare, dwagner
Cc: linux-scsi, target-devel, linux-kernel, kernel-janitors
On Thu, 2021-12-09 at 23:19 +0100, Christophe JAILLET wrote:
> Le 09/12/2021 à 22:57, Joe Perches a écrit :
> > On Thu, 2021-12-09 at 22:51 +0100, Christophe JAILLET wrote:
> > > 'io->sgl' is kzalloced just a few lines above. There is no need to memset
> > > it another time.
> >
> > Better to use kcalloc as well and delete the memset
>
> Sure, thanks for spotting it Joe.
>
> Should a clean v2 be sent or the patch in your reply is enough?
> As your proposal is better than mine, if a v2 is needed, can you do it?
Hi Christophe.
I just wondered about the multiplication in the memset.
You are the patch submitter and noticed it in the first place.
If needed I think you should do it.
cheers, Joe
> > diff --git a/drivers/scsi/elx/efct/efct_io.c b/drivers/scsi/elx/efct/efct_io.c
[]
> > @@ -56,13 +56,12 @@ efct_io_pool_create(struct efct *efct, u32 num_sgl)
> > }
> >
> > /* Allocate SGL */
> > - io->sgl = kzalloc(sizeof(*io->sgl) * num_sgl, GFP_KERNEL);
> > + io->sgl = kcalloc(num_sgl, sizeof(*io->sgl), GFP_KERNEL);
> > if (!io->sgl) {
> > efct_io_pool_free(io_pool);
> > 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] 4+ messages in thread
end of thread, other threads:[~2021-12-09 22:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-09 21:51 [PATCH] scsi: elx: efct: Avoid a useless memset Christophe JAILLET
2021-12-09 21:57 ` Joe Perches
2021-12-09 22:19 ` Christophe JAILLET
2021-12-09 22:29 ` Joe Perches
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.