diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-26 17:43:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-27 12:12:50 -0400 |
commit | 87575437d8173c7da48a4dee25399807c7bec9cb (patch) | |
tree | 38937f38ab2ad2ea5105c689f2924db4f61e0de2 | |
parent | 56d611a04fb2db77334e06274de4daed92e2c626 (diff) |
drivers/char/ppdev.c: 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>
Cc: Michael Buesch <mb@bu3sch.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/char/ppdev.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index fdd37543aa79..02abfddce45a 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c | |||
@@ -287,12 +287,10 @@ static int register_device (int minor, struct pp_struct *pp) | |||
287 | char *name; | 287 | char *name; |
288 | int fl; | 288 | int fl; |
289 | 289 | ||
290 | name = kmalloc (strlen (CHRDEV) + 3, GFP_KERNEL); | 290 | name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor); |
291 | if (name == NULL) | 291 | if (name == NULL) |
292 | return -ENOMEM; | 292 | return -ENOMEM; |
293 | 293 | ||
294 | sprintf (name, CHRDEV "%x", minor); | ||
295 | |||
296 | port = parport_find_number (minor); | 294 | port = parport_find_number (minor); |
297 | if (!port) { | 295 | if (!port) { |
298 | printk (KERN_WARNING "%s: no associated port!\n", name); | 296 | printk (KERN_WARNING "%s: no associated port!\n", name); |