public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] use kzalloc
@ 2022-03-12 10:26 Julia Lawall
  2022-03-12 10:27 ` [PATCH 4/6] scsi: lpfc: " Julia Lawall
  2022-03-14 20:30 ` [PATCH 0/6] " patchwork-bot+netdevbpf
  0 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2022-03-12 10:26 UTC (permalink / raw)
  To: linux-wireless
  Cc: kernel-janitors, alsa-devel, samba-technical, linux-cifs,
	linux-kernel, netdev, linux-rdma, linux-scsi, Andrey Konovalov,
	linux-usb

Use kzalloc instead of kmalloc + memset.

---

 drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
 drivers/net/wireless/zydas/zd1201.c        |    3 +--
 drivers/scsi/lpfc/lpfc_debugfs.c           |    9 ++-------
 drivers/usb/gadget/legacy/raw_gadget.c     |    3 +--
 fs/cifs/transport.c                        |    3 +--
 sound/core/seq/oss/seq_oss_init.c          |    3 +--
 6 files changed, 7 insertions(+), 17 deletions(-)

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

* [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-12 10:26 [PATCH 0/6] use kzalloc Julia Lawall
@ 2022-03-12 10:27 ` Julia Lawall
  2022-03-12 21:45   ` Joe Perches
  2022-03-14 20:30 ` [PATCH 0/6] " patchwork-bot+netdevbpf
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: James Smart
  Cc: kernel-janitors, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel

Use kzalloc instead of kmalloc + memset.

The semantic patch that makes this change is:
(https://coccinelle.gitlabpages.inria.fr/website/)

//<smpl>
@@
expression res, size, flag;
@@
- res = kmalloc(size, flag);
+ res = kzalloc(size, flag);
  ...
- memset(res, 0, size);
//</smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 drivers/scsi/lpfc/lpfc_debugfs.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 30fac2f6fb06..7c4a71703065 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
 				 phba->hba_debugfs_root,
 				 phba, &lpfc_debugfs_op_slow_ring_trc);
 		if (!phba->slow_ring_trc) {
-			phba->slow_ring_trc = kmalloc(
-				(sizeof(struct lpfc_debugfs_trc) *
-				lpfc_debugfs_max_slow_ring_trc),
-				GFP_KERNEL);
+			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
+						      GFP_KERNEL);
 			if (!phba->slow_ring_trc) {
 				lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 						 "0416 Cannot create debugfs "
@@ -6283,9 +6281,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
 				goto debug_failed;
 			}
 			atomic_set(&phba->slow_ring_trc_cnt, 0);
-			memset(phba->slow_ring_trc, 0,
-				(sizeof(struct lpfc_debugfs_trc) *
-				lpfc_debugfs_max_slow_ring_trc));
 		}
 
 		snprintf(name, sizeof(name), "nvmeio_trc");


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

* Re: [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-12 10:27 ` [PATCH 4/6] scsi: lpfc: " Julia Lawall
@ 2022-03-12 21:45   ` Joe Perches
  2022-03-14 11:34     ` Dan Carpenter
  0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2022-03-12 21:45 UTC (permalink / raw)
  To: Julia Lawall, James Smart
  Cc: kernel-janitors, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel

On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> Use kzalloc instead of kmalloc + memset.
[]
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
[]
> @@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>  				 phba->hba_debugfs_root,
>  				 phba, &lpfc_debugfs_op_slow_ring_trc);
>  		if (!phba->slow_ring_trc) {
> -			phba->slow_ring_trc = kmalloc(
> -				(sizeof(struct lpfc_debugfs_trc) *
> -				lpfc_debugfs_max_slow_ring_trc),
> -				GFP_KERNEL);
> +			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
> +						      GFP_KERNEL);

kcalloc



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

* Re: [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-12 21:45   ` Joe Perches
@ 2022-03-14 11:34     ` Dan Carpenter
  2022-03-14 11:50       ` Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2022-03-14 11:34 UTC (permalink / raw)
  To: Joe Perches
  Cc: Julia Lawall, James Smart, kernel-janitors, Dick Kennedy,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel, Harshit Mogalapalli

On Sat, Mar 12, 2022 at 01:45:01PM -0800, Joe Perches wrote:
> On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> > Use kzalloc instead of kmalloc + memset.
> []
> > diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
> []
> > @@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
> >  				 phba->hba_debugfs_root,
> >  				 phba, &lpfc_debugfs_op_slow_ring_trc);
> >  		if (!phba->slow_ring_trc) {
> > -			phba->slow_ring_trc = kmalloc(
> > -				(sizeof(struct lpfc_debugfs_trc) *
> > -				lpfc_debugfs_max_slow_ring_trc),
> > -				GFP_KERNEL);
> > +			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
> > +						      GFP_KERNEL);
> 
> kcalloc
> 

Did someone have a Coccinelle script that converted kzalloc() to
kcalloc()?

regards,
dan carpenter

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

* Re: [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-14 11:34     ` Dan Carpenter
@ 2022-03-14 11:50       ` Julia Lawall
  0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2022-03-14 11:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Joe Perches, James Smart, kernel-janitors, Dick Kennedy,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel, Harshit Mogalapalli, Kees Cook



On Mon, 14 Mar 2022, Dan Carpenter wrote:

> On Sat, Mar 12, 2022 at 01:45:01PM -0800, Joe Perches wrote:
> > On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> > > Use kzalloc instead of kmalloc + memset.
> > []
> > > diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
> > []
> > > @@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
> > >  				 phba->hba_debugfs_root,
> > >  				 phba, &lpfc_debugfs_op_slow_ring_trc);
> > >  		if (!phba->slow_ring_trc) {
> > > -			phba->slow_ring_trc = kmalloc(
> > > -				(sizeof(struct lpfc_debugfs_trc) *
> > > -				lpfc_debugfs_max_slow_ring_trc),
> > > -				GFP_KERNEL);
> > > +			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
> > > +						      GFP_KERNEL);
> >
> > kcalloc
> >
>
> Did someone have a Coccinelle script that converted kzalloc() to
> kcalloc()?

Not sure if I have ever done that.  A long time ago, I made one that
starts with kmalloc and picks kzalloc or kcalloc.  Perhaps Kees did such a
thing?

I'll see if it would be useful.

julia

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

* Re: [PATCH 0/6] use kzalloc
  2022-03-12 10:26 [PATCH 0/6] use kzalloc Julia Lawall
  2022-03-12 10:27 ` [PATCH 4/6] scsi: lpfc: " Julia Lawall
@ 2022-03-14 20:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-14 20:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-wireless, kernel-janitors, alsa-devel, samba-technical,
	linux-cifs, linux-kernel, netdev, linux-rdma, linux-scsi,
	andreyknvl, linux-usb

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 12 Mar 2022 11:26:59 +0100 you wrote:
> Use kzalloc instead of kmalloc + memset.
> 
> ---
> 
>  drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
>  drivers/net/wireless/zydas/zd1201.c        |    3 +--
>  drivers/scsi/lpfc/lpfc_debugfs.c           |    9 ++-------
>  drivers/usb/gadget/legacy/raw_gadget.c     |    3 +--
>  fs/cifs/transport.c                        |    3 +--
>  sound/core/seq/oss/seq_oss_init.c          |    3 +--
>  6 files changed, 7 insertions(+), 17 deletions(-)

Here is the summary with links:
  - [2/6] net/mlx4_en: use kzalloc
    https://git.kernel.org/netdev/net-next/c/3c2dfb735b4a
  - [5/6] zd1201: use kzalloc
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-03-14 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-12 10:26 [PATCH 0/6] use kzalloc Julia Lawall
2022-03-12 10:27 ` [PATCH 4/6] scsi: lpfc: " Julia Lawall
2022-03-12 21:45   ` Joe Perches
2022-03-14 11:34     ` Dan Carpenter
2022-03-14 11:50       ` Julia Lawall
2022-03-14 20:30 ` [PATCH 0/6] " patchwork-bot+netdevbpf

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