X-GM-THRID: 6257098330259587072 X-Received: by 10.112.200.68 with SMTP id jq4mr2351025lbc.3.1456844520206; Tue, 01 Mar 2016 07:02:00 -0800 (PST) X-BeenThere: outreachy-kernel@googlegroups.com Received: by 10.28.128.14 with SMTP id b14ls173943wmd.33.canary; Tue, 01 Mar 2016 07:01:59 -0800 (PST) X-Received: by 10.194.85.169 with SMTP id i9mr2425782wjz.4.1456844519580; Tue, 01 Mar 2016 07:01:59 -0800 (PST) Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr. [192.134.164.104]) by gmr-mx.google.com with ESMTPS id v68si341163wmd.1.2016.03.01.07.01.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Mar 2016 07:01:59 -0800 (PST) Received-SPF: neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of julia.lawall@lip6.fr) client-ip=192.134.164.104; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of julia.lawall@lip6.fr) smtp.mailfrom=julia.lawall@lip6.fr X-IronPort-AV: E=Sophos;i="5.22,523,1449529200"; d="scan'208";a="166508691" Received: from vaio-julia.rsr.lip6.fr ([132.227.76.33]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Mar 2016 16:01:59 +0100 Date: Tue, 1 Mar 2016 16:01:53 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Bhumika Goyal cc: outreachy-kernel@googlegroups.com Subject: Re: [Outreachy kernel] [PATCH] Staging: rtl8192e: Use kzalloc instead of kmalloc and memset In-Reply-To: <1456844212-29057-1-git-send-email-bhumirks@gmail.com> Message-ID: References: <1456844212-29057-1-git-send-email-bhumirks@gmail.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 1 Mar 2016, Bhumika Goyal wrote: > 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. > 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 > --- > drivers/staging/rtl8192e/rtllib_tx.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c > index 58fc70e..1642f29 100644 > --- a/drivers/staging/rtl8192e/rtllib_tx.c > +++ b/drivers/staging/rtl8192e/rtllib_tx.c > @@ -221,12 +221,11 @@ static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, > struct rtllib_txb *txb; > int i; > > - txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), > + txb = kzalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), > gfp_mask); > if (!txb) > return NULL; > > - memset(txb, 0, sizeof(struct rtllib_txb)); The sizes are not the same. I don't know if this is a performance issue. julia > txb->nr_frags = nr_frags; > txb->frag_size = cpu_to_le16(txb_size); > > -- > 1.9.1 > > -- > You received this message because you are subscribed to the Google Groups "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com. > To post to this group, send email to outreachy-kernel@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1456844212-29057-1-git-send-email-bhumirks%40gmail.com. > For more options, visit https://groups.google.com/d/optout. >