From 7a6cb0d5497418599d2125b670926b75e673861c Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 13 May 2010 22:00:05 +0200 Subject: Staging: Use kcalloc or kzalloc Use kcalloc or kzalloc rather than the combination of kmalloc and memset. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ 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)); @@ expression x,size,flags; statement S; @@ -x = kmalloc(size,flags); +x = kzalloc(size,flags); if (x == NULL) S -memset(x, 0, size); // Signed-off-by: Julia Lawall --- drivers/staging/wlan-ng/p80211conv.c | 3 +-- drivers/staging/wlan-ng/prism2fw.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging/wlan-ng') diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 71c3595..059e150 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -601,7 +601,7 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) } /* Allocate the rxmeta */ - rxmeta = kmalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC); + rxmeta = kzalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC); if (rxmeta == NULL) { printk(KERN_ERR "%s: Failed to allocate rxmeta.\n", @@ -611,7 +611,6 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) } /* Initialize the rxmeta */ - memset(rxmeta, 0, sizeof(p80211_rxmeta_t)); rxmeta->wlandev = wlandev; rxmeta->hosttime = jiffies; diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index fc2d8f4..d20c879 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -536,13 +536,12 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt) /* Allocate buffer space for chunks */ for (i = 0; i < *ccnt; i++) { - clist[i].data = kmalloc(clist[i].len, GFP_KERNEL); + clist[i].data = kzalloc(clist[i].len, GFP_KERNEL); if (clist[i].data == NULL) { printk(KERN_ERR "failed to allocate image space, exitting.\n"); return 1; } - memset(clist[i].data, 0, clist[i].len); pr_debug("chunk[%d]: addr=0x%06x len=%d\n", i, clist[i].addr, clist[i].len); } -- cgit v1.1