diff options
author | Julia Lawall <julia@diku.dk> | 2010-03-10 16:15:19 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-03-18 11:04:09 -0400 |
commit | 4d682420cead1ce06d8cd44ae193414404f0e7f5 (patch) | |
tree | 964bf2574e5c3f2df7a46c7ad59684f818bd96fb /drivers/mtd/devices | |
parent | 42c259193ef3934733e300fefd3f0d0bb3576f3f (diff) |
mtd: block2mtd: Use kasprintf
kasprintf combines kmalloc and sprintf, and takes care of the size
calculation itself.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,flag;
expression list args;
statement S;
@@
a =
- \(kmalloc\|kzalloc\)(...,flag)
+ kasprintf(flag,args)
<... when != a
if (a == NULL || ...) S
...>
- sprintf(a,args);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd/devices')
-rw-r--r-- | drivers/mtd/devices/block2mtd.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 8c295f40d2ac..4281f3e0cf7f 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -275,12 +275,10 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
275 | 275 | ||
276 | /* Setup the MTD structure */ | 276 | /* Setup the MTD structure */ |
277 | /* make the name contain the block device in */ | 277 | /* make the name contain the block device in */ |
278 | name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1, | 278 | name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname); |
279 | GFP_KERNEL); | ||
280 | if (!name) | 279 | if (!name) |
281 | goto devinit_err; | 280 | goto devinit_err; |
282 | 281 | ||
283 | sprintf(name, "block2mtd: %s", devname); | ||
284 | dev->mtd.name = name; | 282 | dev->mtd.name = name; |
285 | 283 | ||
286 | dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; | 284 | dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; |