diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-17 04:00:22 -0400 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2010-05-17 04:00:18 -0400 |
commit | 777a5510093a6d6443351160c6969a0e66f3ba8a (patch) | |
tree | d5759bb78129a4817e79b675893728b8d68770d8 /drivers/s390/char/keyboard.c | |
parent | ab3c68ee5fd329ba48094d3417fd60e30ea14a87 (diff) |
[S390] drivers/s390/char: Use kstrdup
Use kstrdup when the goal of an allocation is copy a string into the
allocated region. Additionally drop the now unused variable len.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression from,to;
expression flag,E1,E2;
statement S;
@@
- to = kmalloc(strlen(from) + 1,flag);
+ to = kstrdup(from, flag);
... when != \(from = E1 \| to = E1 \)
if (to==NULL || ...) S
... when != \(from = E2 \| to = E2 \)
- strcpy(to, from);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/char/keyboard.c')
-rw-r--r-- | drivers/s390/char/keyboard.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c index cb6bffe7141a..24021fd7de25 100644 --- a/drivers/s390/char/keyboard.c +++ b/drivers/s390/char/keyboard.c | |||
@@ -49,7 +49,7 @@ static unsigned char ret_diacr[NR_DEAD] = { | |||
49 | struct kbd_data * | 49 | struct kbd_data * |
50 | kbd_alloc(void) { | 50 | kbd_alloc(void) { |
51 | struct kbd_data *kbd; | 51 | struct kbd_data *kbd; |
52 | int i, len; | 52 | int i; |
53 | 53 | ||
54 | kbd = kzalloc(sizeof(struct kbd_data), GFP_KERNEL); | 54 | kbd = kzalloc(sizeof(struct kbd_data), GFP_KERNEL); |
55 | if (!kbd) | 55 | if (!kbd) |
@@ -72,11 +72,10 @@ kbd_alloc(void) { | |||
72 | goto out_maps; | 72 | goto out_maps; |
73 | for (i = 0; i < ARRAY_SIZE(func_table); i++) { | 73 | for (i = 0; i < ARRAY_SIZE(func_table); i++) { |
74 | if (func_table[i]) { | 74 | if (func_table[i]) { |
75 | len = strlen(func_table[i]) + 1; | 75 | kbd->func_table[i] = kstrdup(func_table[i], |
76 | kbd->func_table[i] = kmalloc(len, GFP_KERNEL); | 76 | GFP_KERNEL); |
77 | if (!kbd->func_table[i]) | 77 | if (!kbd->func_table[i]) |
78 | goto out_func; | 78 | goto out_func; |
79 | memcpy(kbd->func_table[i], func_table[i], len); | ||
80 | } | 79 | } |
81 | } | 80 | } |
82 | kbd->fn_handler = | 81 | kbd->fn_handler = |