[svn-commits] sruffell: linux/trunk r9947 - /linux/trunk/drivers/dahdi/wcte12xp/base.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 2 15:02:13 CDT 2011


Author: sruffell
Date: Thu Jun  2 15:02:08 2011
New Revision: 9947

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9947
Log:
wcte12xp: kmalloc/memset -> kzalloc.

This is trivial cleanup. Fixing up a couple of places that followed a
kmalloc with a memset to 0 and also sneaked in one ARRAY_SIZE usage
change.

Signed-off-by: Shaun Ruffell <sruffell at digium.com>

Modified:
    linux/trunk/drivers/dahdi/wcte12xp/base.c

Modified: linux/trunk/drivers/dahdi/wcte12xp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wcte12xp/base.c?view=diff&rev=9947&r1=9946&r2=9947
==============================================================================
--- linux/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcte12xp/base.c Thu Jun  2 15:02:08 2011
@@ -2272,7 +2272,7 @@
 	int res;
 	unsigned int index = -1;
 
-	for (x = 0; x < sizeof(ifaces) / sizeof(ifaces[0]); x++) {
+	for (x = 0; x < ARRAY_SIZE(ifaces); x++) {
 		if (!ifaces[x]) {
 			index = x;
 			break;
@@ -2285,12 +2285,12 @@
 		return -EIO;
 	}
 	
-	if (!(wc = kmalloc(sizeof(*wc), GFP_KERNEL))) {
+	wc = kzalloc(sizeof(*wc), GFP_KERNEL);
+	if (!wc)
 		return -ENOMEM;
-	}
 
 	ifaces[index] = wc;
-	memset(wc, 0, sizeof(*wc));
+
 	wc->ledstate = -1;
 	spin_lock_init(&wc->reglock);
 	INIT_LIST_HEAD(&wc->active_cmds);
@@ -2374,18 +2374,19 @@
 	}
 
 	for (x = 0; x < (wc->spantype == TYPE_E1 ? 31 : 24); x++) {
-		if (!(wc->chans[x] = kmalloc(sizeof(*wc->chans[x]), GFP_KERNEL))) {
+		wc->chans[x] = kzalloc(sizeof(*wc->chans[x]), GFP_KERNEL);
+		if (!wc->chans[x]) {
 			free_wc(wc);
 			ifaces[index] = NULL;
 			return -ENOMEM;
 		}
-		memset(wc->chans[x], 0, sizeof(*wc->chans[x]));
-		if (!(wc->ec[x] = kmalloc(sizeof(*wc->ec[x]), GFP_KERNEL))) {
+
+		wc->ec[x] = kzalloc(sizeof(*wc->ec[x]), GFP_KERNEL);
+		if (!wc->ec[x]) {
 			free_wc(wc);
 			ifaces[index] = NULL;
 			return -ENOMEM;
 		}
-		memset(wc->ec[x], 0, sizeof(*wc->ec[x]));
 	}
 
 	mod_timer(&wc->timer, jiffies + HZ/5);




More information about the svn-commits mailing list