mtd: block2mtd: Use kasprintf
authorJulia Lawall <julia@diku.dk>
Wed, 10 Mar 2010 21:15:19 +0000 (22:15 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 18 Mar 2010 15:04:09 +0000 (15:04 +0000)
commit4d682420cead1ce06d8cd44ae193414404f0e7f5
tree964bf2574e5c3f2df7a46c7ad59684f818bd96fb
parent42c259193ef3934733e300fefd3f0d0bb3576f3f
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>
drivers/mtd/devices/block2mtd.c