kmalloc + memzero -> kzalloc conversion
PATCH 1/1 kmalloc + memzero -> kzalloc conversion
We have the API, so use it.
drivers/mtd/maps/bast-flash.c +1 -2
@@ -123,14 +123,13 @@ static int bast_flash_probe(struct devicstruct resource *res;int err =0 ; - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (info ==NULL ) { printk(KERN_ERR PFX "no memory for flash info\n"); err = -ENOMEM ; goto exit_error; } -memzero (info,sizeof (*info));dev_set_drvdata (dev, info); res = pdev->resource;/* assume that the flash has one resource */
drivers/mtd/maps/epxa10db-flash.c +1 -2
@@ -142,8 +142,7 @@ static int __init epxa_default_partitionprintk ("Using default partitions for %s\n" ,BOARD_NAME ); npartitions=1 ; - parts =kmalloc (npartitions*sizeof (*parts)+strlen (name),GFP_KERNEL ); -memzero (parts,npartitions*sizeof (*parts)+strlen (name)); + parts =kzalloc (npartitions*sizeof (*parts)+strlen (name),GFP_KERNEL );if (!parts) { ret = -ENOMEM ; goto out;
drivers/mtd/maps/ixp2000.c +1 -2
@@ -168,12 +168,11 @@ static int ixp2000_flash_probe(struct dereturn -EIO ; } - info =kmalloc (sizeof (struct ixp2000_flash_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct ixp2000_flash_info ),GFP_KERNEL );if (!info) { err = -ENOMEM ; goto Error; } -memzero (info,sizeof (struct ixp2000_flash_info ));dev_set_drvdata (&dev->dev, info);
drivers/mtd/maps/ixp4xx.c +1 -2
@@ -153,12 +153,11 @@ static int ixp4xx_flash_probe(struct devreturn err; } - info =kmalloc (sizeof (struct ixp4xx_flash_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct ixp4xx_flash_info ),GFP_KERNEL );if (!info) { err = -ENOMEM ; goto Error; } -memzero (info,sizeof (struct ixp4xx_flash_info ));dev_set_drvdata (&dev->dev, info);
Signature · 3 lines
Deepak Saxena - [email protected] - http://www.plexity.net Even a stopped clock gives the right time twice a day.
Quoted 4 lines · Deepak Saxena
We have the API, so use it.
Signed-off-by Deepak Saxena <[email protected]>
Well, does it really hurt if one does kmalloc() + memset(zero) instead? Is it worth fixing this? Doubts.
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
On Oct 01 2005, at 11:46, Artem B. Bityutskiy was caught saying:
Quoted 6 lines · Deepak Saxena
Quoted 4 lines
We have the API, so use it.
Signed-off-by Deepak Saxena <[email protected]>Well, does it really hurt if one does
kmalloc()+ memset(zero) instead? Is it worth fixing this? Doubts.
I see it more as an API usage cleanup then a "fix" of any sort.
~Deepak
Signature · 3 lines
Deepak Saxena - [email protected] - http://www.plexity.net Even a stopped clock gives the right time twice a day.
Quoted 2 lines · Deepak Saxena
I see it more as an API usage cleanup then a "fix" of any sort.
Well, actually it may be helpful in only future, for example, if it is known that the allocated memory is zero-filled already, memzero() may be avoided at all.
Signature · 3 lines
Best Regards, Artem B. Bityuckiy, St.-Petersburg, Russia.
Quoted 6 lines · Artem B. Bityutskiy
Quoted 2 lines · Deepak Saxena
I see it more as an API usage cleanup then a "fix" of any sort.
Well, actually it may be helpful in only future, for example, if it is known that the allocated memory is zero-filled already,
memzero()may be avoided at all.
Even today, kzalloc() takes less code than kmalloc() + memset(). Shrinks your binary size by a tiny amount.
Jörn
Signature · 3 lines
Mundie uses a textbook tactic of manipulation: start with some reasonable talk, and lead the audience to an unreasonable conclusion. -- Bruce Perens
Quoted 1 line · Deepak Saxena
We have the API, so use it.
Ummm. There is a patch in Andrew's tree that allows the use of __GFP_ZERO with slabs in the same way as the page allocator. With that functionality kmalloc_node will also be able to zero stuff.