public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: dsaxena@plexity.net
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [IDE] kmalloc + memset -> kzalloc conversion
Date: Sat, 01 Oct 2005 13:08:22 +0200	[thread overview]
Message-ID: <433E6E26.5030305@gmail.com> (raw)
In-Reply-To: <20051001074415.GL25424@plexity.net>

Deepak Saxena napsal(a):

>Signed-off-by: Deepak Saxena <dsaxena@plexity.net>
>
>diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
>--- a/drivers/ide/ide-cd.c
>+++ b/drivers/ide/ide-cd.c
>@@ -3449,7 +3449,7 @@ static int ide_cd_probe(struct device *d
> 		printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
> 		goto failed;
> 	}
>-	info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
>+	info = (struct cdrom_info *) kzalloc (sizeof (struct cdrom_info), GFP_KERNEL);
>  
>
no need to cast and 80 chars on a line is upper bound.

> 	if (info == NULL) {
> 		printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
> 		goto failed;
>@@ -3463,8 +3463,6 @@ static int ide_cd_probe(struct device *d
> 
> 	ide_register_subdriver(drive, &ide_cdrom_driver);
> 
>-	memset(info, 0, sizeof (struct cdrom_info));
>-
> 	kref_init(&info->kref);
> 
> 	info->drive = drive;
>diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
>--- a/drivers/ide/ide-disk.c
>+++ b/drivers/ide/ide-disk.c
>@@ -1215,7 +1215,7 @@ static int ide_disk_probe(struct device 
> 	if (drive->media != ide_disk)
> 		goto failed;
> 
>-	idkp = kmalloc(sizeof(*idkp), GFP_KERNEL);
>+	idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
> 	if (!idkp)
> 		goto failed;
> 
>@@ -1228,8 +1228,6 @@ static int ide_disk_probe(struct device 
> 
> 	ide_register_subdriver(drive, &idedisk_driver);
> 
>-	memset(idkp, 0, sizeof(*idkp));
>-
> 	kref_init(&idkp->kref);
> 
> 	idkp->drive = drive;
>diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
>--- a/drivers/ide/ide-floppy.c
>+++ b/drivers/ide/ide-floppy.c
>@@ -2146,7 +2146,7 @@ static int ide_floppy_probe(struct devic
> 		printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name);
> 		goto failed;
> 	}
>-	if ((floppy = (idefloppy_floppy_t *) kmalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
>+	if ((floppy = (idefloppy_floppy_t *) kzalloc (sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) {
>  
>
detto

> 		printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
> 		goto failed;
> 	}
>@@ -2159,8 +2159,6 @@ static int ide_floppy_probe(struct devic
> 
> 	ide_register_subdriver(drive, &idefloppy_driver);
> 
>-	memset(floppy, 0, sizeof(*floppy));
>-
> 	kref_init(&floppy->kref);
> 
> 	floppy->drive = drive;
>diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
>--- a/drivers/ide/ide-probe.c
>+++ b/drivers/ide/ide-probe.c
>@@ -596,14 +596,13 @@ static inline u8 probe_for_drive (ide_dr
> 	 *	Also note that 0 everywhere means "can't do X"
> 	 */
>  
>-	drive->id = kmalloc(SECTOR_WORDS *4, GFP_KERNEL);
>+	drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL);
> 	drive->id_read = 0;
> 	if(drive->id == NULL)
> 	{
> 		printk(KERN_ERR "ide: out of memory for id data.\n");
> 		return 0;
> 	}
>-	memset(drive->id, 0, SECTOR_WORDS * 4);
> 	strcpy(drive->id->model, "UNKNOWN");
> 	
> 	/* skip probing? */
>@@ -1097,14 +1096,13 @@ static int init_irq (ide_hwif_t *hwif)
> 		hwgroup->hwif->next = hwif;
> 		spin_unlock_irq(&ide_lock);
> 	} else {
>-		hwgroup = kmalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
>+		hwgroup = kzalloc_node(sizeof(ide_hwgroup_t), GFP_KERNEL,
> 					hwif_to_node(hwif->drives[0].hwif));
> 		if (!hwgroup)
> 	       		goto out_up;
> 
> 		hwif->hwgroup = hwgroup;
> 
>-		memset(hwgroup, 0, sizeof(ide_hwgroup_t));
> 		hwgroup->hwif     = hwif->next = hwif;
> 		hwgroup->rq       = NULL;
> 		hwgroup->handler  = NULL;
>diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
>--- a/drivers/ide/ide-tape.c
>+++ b/drivers/ide/ide-tape.c
>@@ -4844,7 +4844,7 @@ static int ide_tape_probe(struct device 
> 		printk(KERN_WARNING "ide-tape: Use drive %s with ide-scsi emulation and osst.\n", drive->name);
> 		printk(KERN_WARNING "ide-tape: OnStream support will be removed soon from ide-tape!\n");
> 	}
>-	tape = (idetape_tape_t *) kmalloc (sizeof (idetape_tape_t), GFP_KERNEL);
>+	tape = (idetape_tape_t *) kzalloc (sizeof (idetape_tape_t), GFP_KERNEL);
>  
>
... and so on

regards,

-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
~\-/~      jirislaby@gmail.com      ~\-/~
241B347EC88228DE51EE A49C4A73A25004CB2A10


  reply	other threads:[~2005-10-01 11:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-01  7:44 [PATCH] [IDE] kmalloc + memset -> kzalloc conversion Deepak Saxena
2005-10-01 11:08 ` Jiri Slaby [this message]
2005-10-01 11:18   ` Jiri Slaby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=433E6E26.5030305@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=akpm@osdl.org \
    --cc=dsaxena@plexity.net \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox