* [PATCH] aic7xxx: use kzalloc instead of kmalloc + memset
@ 2013-03-10 12:26 Silviu-Mihai Popescu
2013-03-12 6:47 ` Silviu Popescu
0 siblings, 1 reply; 2+ messages in thread
From: Silviu-Mihai Popescu @ 2013-03-10 12:26 UTC (permalink / raw)
To: linux-scsi; +Cc: hare, JBottomley, linux-kernel
This replaces a call to kmalloc() followed by memset() with just one
call to kzalloc(). This was found using make coccicheck.
Signed-off-by: Silviu-Mihai Popescu <silviupopescu1990@gmail.com>
---
drivers/scsi/aic7xxx/aic7xxx_core.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 10172a3..7f34d25 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -4464,10 +4464,9 @@ ahc_softc_init(struct ahc_softc *ahc)
ahc->pause = ahc->unpause | PAUSE;
/* XXX The shared scb data stuff should be deprecated */
if (ahc->scb_data == NULL) {
- ahc->scb_data = kmalloc(sizeof(*ahc->scb_data), GFP_ATOMIC);
+ ahc->scb_data = kzalloc(sizeof(*ahc->scb_data), GFP_ATOMIC);
if (ahc->scb_data == NULL)
return (ENOMEM);
- memset(ahc->scb_data, 0, sizeof(*ahc->scb_data));
}
return (0);
@@ -4780,10 +4779,9 @@ ahc_init_scbdata(struct ahc_softc *ahc)
SLIST_INIT(&scb_data->sg_maps);
/* Allocate SCB resources */
- scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
+ scb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
if (scb_data->scbarray == NULL)
return (ENOMEM);
- memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
/* Determine the number of hardware SCBs and initialize them */
@@ -7558,14 +7556,13 @@ ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb)
return;
}
}
- lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
+ lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
if (lstate == NULL) {
xpt_print_path(ccb->ccb_h.path);
printk("Couldn't allocate lstate\n");
ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
return;
}
- memset(lstate, 0, sizeof(*lstate));
status = xpt_create_path(&lstate->path, /*periph*/NULL,
xpt_path_path_id(ccb->ccb_h.path),
xpt_path_target_id(ccb->ccb_h.path),
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] aic7xxx: use kzalloc instead of kmalloc + memset
2013-03-10 12:26 [PATCH] aic7xxx: use kzalloc instead of kmalloc + memset Silviu-Mihai Popescu
@ 2013-03-12 6:47 ` Silviu Popescu
0 siblings, 0 replies; 2+ messages in thread
From: Silviu Popescu @ 2013-03-12 6:47 UTC (permalink / raw)
To: linux-scsi; +Cc: hare, JBottomley, linux-kernel
On Sun, Mar 10, 2013 at 2:26 PM, Silviu-Mihai Popescu
<silviupopescu1990@gmail.com> wrote:
> This replaces a call to kmalloc() followed by memset() with just one
> call to kzalloc(). This was found using make coccicheck.
>
> Signed-off-by: Silviu-Mihai Popescu <silviupopescu1990@gmail.com>
> ---
> drivers/scsi/aic7xxx/aic7xxx_core.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
> index 10172a3..7f34d25 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_core.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
> @@ -4464,10 +4464,9 @@ ahc_softc_init(struct ahc_softc *ahc)
> ahc->pause = ahc->unpause | PAUSE;
> /* XXX The shared scb data stuff should be deprecated */
> if (ahc->scb_data == NULL) {
> - ahc->scb_data = kmalloc(sizeof(*ahc->scb_data), GFP_ATOMIC);
> + ahc->scb_data = kzalloc(sizeof(*ahc->scb_data), GFP_ATOMIC);
> if (ahc->scb_data == NULL)
> return (ENOMEM);
> - memset(ahc->scb_data, 0, sizeof(*ahc->scb_data));
> }
>
> return (0);
> @@ -4780,10 +4779,9 @@ ahc_init_scbdata(struct ahc_softc *ahc)
> SLIST_INIT(&scb_data->sg_maps);
>
> /* Allocate SCB resources */
> - scb_data->scbarray = kmalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> + scb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, GFP_ATOMIC);
> if (scb_data->scbarray == NULL)
> return (ENOMEM);
> - memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX_ALLOC);
>
> /* Determine the number of hardware SCBs and initialize them */
>
> @@ -7558,14 +7556,13 @@ ahc_handle_en_lun(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb)
> return;
> }
> }
> - lstate = kmalloc(sizeof(*lstate), GFP_ATOMIC);
> + lstate = kzalloc(sizeof(*lstate), GFP_ATOMIC);
> if (lstate == NULL) {
> xpt_print_path(ccb->ccb_h.path);
> printk("Couldn't allocate lstate\n");
> ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
> return;
> }
> - memset(lstate, 0, sizeof(*lstate));
> status = xpt_create_path(&lstate->path, /*periph*/NULL,
> xpt_path_path_id(ccb->ccb_h.path),
> xpt_path_target_id(ccb->ccb_h.path),
> --
> 1.7.9.5
>
Hello,
Would anyone be so kind as to review this?
Thanks,
Silviu Popescu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-12 6:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-10 12:26 [PATCH] aic7xxx: use kzalloc instead of kmalloc + memset Silviu-Mihai Popescu
2013-03-12 6:47 ` Silviu Popescu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox