diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-13 22:00:05 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-14 14:02:56 -0700 |
commit | 7a6cb0d5497418599d2125b670926b75e673861c (patch) | |
tree | a698dc86695304ef6aefe4bc6d18fdad7f3770ee /drivers/staging/vt6655 | |
parent | b5a2104c98cb603f7053e4b0309fb88f15d6be86 (diff) | |
download | op-kernel-dev-7a6cb0d5497418599d2125b670926b75e673861c.zip op-kernel-dev-7a6cb0d5497418599d2125b670926b75e673861c.tar.gz |
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/)
// <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));
@@
expression x,size,flags;
statement S;
@@
-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
if (x == NULL) S
-memset(x, 0, size);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Diffstat (limited to 'drivers/staging/vt6655')
-rw-r--r-- | drivers/staging/vt6655/hostap.c | 3 | ||||
-rw-r--r-- | drivers/staging/vt6655/wpactl.c | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index fb7775c..195cc36 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -90,10 +90,9 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name); - pDevice->apdev = kmalloc(sizeof(struct net_device), GFP_KERNEL); + pDevice->apdev = kzalloc(sizeof(struct net_device), GFP_KERNEL); if (pDevice->apdev == NULL) return -ENOMEM; - memset(pDevice->apdev, 0, sizeof(struct net_device)); apdev_priv = netdev_priv(pDevice->apdev); *apdev_priv = *pDevice; diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index e5e618e..9f215df 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -681,13 +681,12 @@ static int wpa_get_scan(PSDevice pDevice, count++; }; - pBuf = kmalloc(sizeof(struct viawget_scan_result) * count, (int)GFP_ATOMIC); + pBuf = kcalloc(count, sizeof(struct viawget_scan_result), (int)GFP_ATOMIC); if (pBuf == NULL) { ret = -ENOMEM; return ret; } - memset(pBuf, 0, sizeof(struct viawget_scan_result) * count); scan_buf = (struct viawget_scan_result *)pBuf; pBSS = &(pMgmt->sBSSList[0]); for (ii = 0, jj = 0; ii < MAX_BSS_NUM ; ii++) { |