[PATCH 17/20] arch/x86/kernel: Use kcalloc

From: Julia Lawall
Date: Thu May 13 2010 - 16:06:53 EST


From: Julia Lawall <julia@xxxxxxx>

Use kcalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,y,flags;
statement S;
type T;
@@

x =
- kmalloc
+ kcalloc
(
- y * sizeof(T),
+ y, sizeof(T),
flags);
if (x == NULL) S
-memset(x, 0, y * sizeof(T));
// </smpl>

Signed-off-by: Julia Lawall <julia@xxxxxxx>

---
arch/x86/kernel/uv_time.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/x86/kernel/uv_time.c b/arch/x86/kernel/uv_time.c
--- a/arch/x86/kernel/uv_time.c
+++ b/arch/x86/kernel/uv_time.c
@@ -149,10 +149,9 @@ static __init int uv_rtc_allocate_timers
{
int cpu;

- blade_info = kmalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL);
+ blade_info = kcalloc(uv_possible_blades, sizeof(void *), GFP_KERNEL);
if (!blade_info)
return -ENOMEM;
- memset(blade_info, 0, uv_possible_blades * sizeof(void *));

for_each_present_cpu(cpu) {
int nid = cpu_to_node(cpu);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/