Staging: rtl8192u: Use kzalloc instead of kmalloc and memset
PATCH 1/1 Staging: rtl8192u: Use kzalloc instead of kmalloc and memset
The code in this patch allocates some memory and then clears it. The function kzalloc does the both so replace kmalloc and memset with kzalloc. Also sizeof(struct ieee80211_txb) can be written as sizeof(*txb) as txb is a pointer of type struct ieee80211_txb. Done using coccinelle:
@@
expression e,e1,e2;
@@
- e=kmalloc(e1,e2);
+ e=kzalloc(e1,e2);
if(!e)
return NULL;
...
- memset(e,...);
--- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +2 -4
@@ -242,13 +242,11 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, {struct ieee80211_txb *txb;int i; - txb =kmalloc ( -sizeof (struct ieee80211_txb ) + (sizeof (u8 *) * nr_frags), - gfp_mask); + txb =kzalloc (sizeof (*txb) + (sizeof (u8 *) * nr_frags), + gfp_mask);if (!txb)return NULL ; -memset (txb,0 ,sizeof (struct ieee80211_txb )); txb->nr_frags = nr_frags; txb->frag_size = txb_size;
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 26 lines · Bhumika Goyal
The code in this patch allocates some memory and then clears it. The function kzalloc does the both so replace kmalloc and memset with kzalloc. Also
sizeof(struct ieee80211_txb)can be written assizeof(*txb)as txb is a pointer of type structieee80211_txb. Done using coccinelle:@@
expression e,e1,e2;
@@
- e=kmalloc(e1,e2);
+ e=kzalloc(e1,e2);
if(!e)
return NULL;
...
-memset(e,...);Signed-off-by Bhumika Goyal <[email protected]>--- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +0
-0
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, · line 246
Quoted 8 lines
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +2
-3@@ -242,13 +242,11 @@ static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, {struct ieee80211_txb *txb;int i; - txb =kmalloc ( -sizeof (struct ieee80211_txb ) + (sizeof (u8 *) * nr_frags), - gfp_mask); + txb =kzalloc (sizeof (*txb) + (sizeof (u8 *) * nr_frags), + gfp_mask);
This no longer needs to be line-wrapped, right?
Please fix.
thanks,
greg k-h