From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7423401132032 X-Google-Groups: outreachy-kernel X-Google-Thread: 9ca63f596c,66aeee52302e9056,start X-Google-Attributes: gid9ca63f596c,domainid0,private,googlegroup X-Google-NewGroupId: yes X-Received: by 10.236.18.232 with SMTP id l68mr31256919yhl.16.1425990129624; Tue, 10 Mar 2015 05:22:09 -0700 (PDT) X-BeenThere: outreachy-kernel@googlegroups.com Received: by 10.107.7.36 with SMTP id 36ls62237ioh.102.gmail; Tue, 10 Mar 2015 05:22:09 -0700 (PDT) X-Received: by 10.66.157.129 with SMTP id wm1mr32005665pab.15.1425990129359; Tue, 10 Mar 2015 05:22:09 -0700 (PDT) Return-Path: Received: from mail-pd0-x22e.google.com (mail-pd0-x22e.google.com. [2607:f8b0:400e:c02::22e]) by gmr-mx.google.com with ESMTPS id ni4si58574pdb.2.2015.03.10.05.22.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 05:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of navyasri.tech@gmail.com designates 2607:f8b0:400e:c02::22e as permitted sender) client-ip=2607:f8b0:400e:c02::22e; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of navyasri.tech@gmail.com designates 2607:f8b0:400e:c02::22e as permitted sender) smtp.mail=navyasri.tech@gmail.com; dkim=pass header.i=@gmail.com; dmarc=pass (p=NONE dis=NONE) header.from=gmail.com Received: by pdno5 with SMTP id o5so1418620pdn.1 for ; Tue, 10 Mar 2015 05:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=FIzmOLBMVrB2hH/8gOOFx/Ht2gPzRLj3TwluQ1YvoqE=; b=W21+m1I1MxYFyD8GzWJ/Zas8507Jo93Z2RTLWC0hc7PJ2o1hJj6Oh8QCvQQ562YbEv vhCoz4H06g1gYyHZ5ZMqbbr19hthJeKTZUFd/ABoXcsioIg/+we3B1yRP1pyAnZJ1IdP Zd9fV4/7hRorIvh9+xWKY7k726C03gWpqns0XTEhkW5r3PDZfYb44pzqV9ipKEsT33Ev I36xf48ZylEONPozdn3DiAf0olyC+3cBWcS+taDsyQoJSx6btyUzKQU05GPWTGWiGmWQ a1gZBjpUq27Hois6RR5Su9mCFieeFH9TFp5fUODIYy2AVzh6A9UlPHRxkOCMAWXVyqIw 7/ow== X-Received: by 10.70.88.137 with SMTP id bg9mr42361177pdb.92.1425990129155; Tue, 10 Mar 2015 05:22:09 -0700 (PDT) Return-Path: Received: from nizamkari ([111.93.6.70]) by mx.google.com with ESMTPSA id qa3sm874359pab.16.2015.03.10.05.22.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Mar 2015 05:22:08 -0700 (PDT) Date: Tue, 10 Mar 2015 17:53:30 +0530 From: Navya Sri Nizamkari To: outreachy-kernel@googlegroups.com Subject: [PATCH v2 0/3] Transform kmalloc calls to kzalloc. Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) [Changes in v2] In version v2, I break the original patchset into two. One for kmalloc -> k{z,c}alloc and other for kzalloc -> kcalloc. This patchset includes patches for kmalloc to kzalloc conversion. [original cover letter] This patchset changes some kzalloc calls to kcalloc and kmalloc to kzalloc. The semantic patch used to make this change is: @@ type T, T2; expression x; identifier f,f1; expression E1,E2,E3,E4; statement S,S1,S2; @@ - x = (T)kmalloc(E1,E2) + x = kzalloc(E1,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( if ((x!=NULL)&&...) { ... when != \(f1(...,x,...)\|<+...x...+>=E4\) when != \(while(...) S1\|for(...;...;...) S1\) - memset((T2)x,0,E1); ... } else S2 | - memset((T2)x,0,E1); ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f,f1; expression E2,E3,E4; statement S,S1,S2; @@ - x = (T)kmalloc(sizeof(T1),E2) + x = kzalloc(sizeof(T1),E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( if ((x!=NULL)&&...) { ... when != \(f1(...,x,...)\|<+...x...+>=E4\) when != \(while(...) S1\|for(...;...;...) S1\) - memset((T2)x,0,sizeof(*y)); ... } else S2 | - memset((T2)x,0,sizeof(*y)); ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f,f1; expression E,E2,E3,E4; statement S,S1,S2; @@ - x = (T)kmalloc(sizeof(T1)*E,E2) + x = kzalloc(sizeof(T1)*E,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( if ((x!=NULL)&&...) { ... when != \(f1(...,x,...)\|<+...x...+>=E4\) when != \(while(...) S1\|for(...;...;...) S1\) - memset((T2)x,0,sizeof(*y)*E); ... } else S2 | - memset((T2)x,0,sizeof(*y)*E); ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f,f1; expression E2,E3,E4; statement S,S1,S2; @@ - x = (T)kmalloc(sizeof(*y),E2) + x = kzalloc(sizeof(*y),E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( if ((x!=NULL)&&...) { ... when != \(f1(...,x,...)\|<+...x...+>=E4\) when != \(while(...) S1\|for(...;...;...) S1\) - memset((T2)x,0,sizeof(T1)); ... } else S2 | - memset((T2)x,0,sizeof(T1)); ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f,f1; expression E,E2,E3,E4; statement S,S1,S2; @@ - x = (T)kmalloc(sizeof(*y)*E,E2) + x = kzalloc(sizeof(*y)*E,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( if ((x!=NULL)&&...) { ... when != \(f1(...,x,...)\|<+...x...+>=E4\) when != \(while(...) S1\|for(...;...;...) S1\) - memset((T2)x,0,sizeof(T1)*E); ... } else S2 | - memset((T2)x,0,sizeof(T1)*E); ) @ disable neg_if, mult_comm @ type T, T2; expression x; identifier f,f1; expression E0,E1,E2,E3,E4; statement S,S1,S2; @@ - x = (T)kmalloc(E0 * E1,E2) + x = kzalloc(E0 * E1,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( if ((x!=NULL)&&...) { ... when != \(f1(...,x,...)\|<+...x...+>=E4\) when != \(while(...) S1\|for(...;...;...) S1\) - memset((T2)x,0,E1 * E0); ... } else S2 | - memset((T2)x,0,E1 * E0); ) // --------------------------------------------------------------------- // --------------------------------------------------------------------- // have to duplicate everything again to make a version with no braces //\(x->fld\|f(...,x,...)\|x=E\) @@ type T, T2; expression x; identifier f; expression E1,E2,E3; statement S,S2; @@ - x = (T)kmalloc(E1,E2) + x = kzalloc(E1,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( - if ((x!=NULL)&&...) memset((T2)x,0,E1); | + if (!x) - if ((x!=NULL)&&...) memset((T2)x,0,E1); else S2 ) @ @ type T, T2; type T1; T1 *x; T1 *y; identifier f; expression E2,E3; statement S,S2; @@ - x = (T)kmalloc(sizeof(T1),E2) + x = kzalloc(sizeof(T1),E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(*y)); | + if (!x) - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(*y)); else S2 ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f; expression E,E2,E3; statement S,S2; @@ - x = (T)kmalloc(sizeof(T1)*E,E2) + x = kzalloc(sizeof(T1)*E,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(*y)*E); | + if (!x) - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(*y)*E); else S2 ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f; expression E2,E3; statement S,S2; @@ - x = (T)kmalloc(sizeof(*y),E2) + x = kzalloc(sizeof(*y),E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(T1)); | + if (!x) - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(T1)); else S2 ) @@ type T, T2; type T1; T1 *x; T1 *y; identifier f; expression E,E2,E3; statement S,S2; @@ - x = (T)kmalloc(sizeof(*y)*E,E2) + x = kzalloc(sizeof(*y)*E,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(T1)*E); | + if (!x) - if ((x!=NULL)&&...) memset((T2)x,0,sizeof(T1)*E); else S2 ) @ disable neg_if, mult_comm @ type T, T2; expression x; identifier f; expression E0,E1,E2,E3; statement S,S2; @@ - x = (T)kmalloc(E0 * E1,E2) + x = kzalloc(E0 * E1,E2) ... when != \(f(...,x,...)\|<+...x...+>=E3\) when != \(while(...) S\|for(...;...;...) S\) ( - if ((x!=NULL)&&...) memset((T2)x,0,E1 * E0); | + if (!x) - if ((x!=NULL)&&...) memset((T2)x,0,E1 * E0); else S2 ) // --------------------------------------------------------------------- @@ expression E; statement S; @@ kzalloc(...) ... if (E) S - else { } // --------------------------------------------------------------------- // --------------------------------------------------------------------- @@ expression E1,E2,E3; @@ - kzalloc(E1*sizeof(E2),E3) + kcalloc(E1,sizeof(E2),E3) @@ expression E1,E3; type T; @@ - kzalloc(E1*sizeof(T),E3) + kcalloc(E1,sizeof(T),E3) @@ expression E1,E2,E3,E4; @@ - kzalloc(E1*E2*sizeof(E3),E4) + kcalloc(E1*E2,sizeof(E3),E4) @@ expression E1,E2,E3; type T; @@ - kzalloc(E1*E2*sizeof(T),E3) + kcalloc(E1*E2,sizeof(T),E3) @@ expression E1,E2,E3,E4; @@ - kzalloc(sizeof(E3)*E1*E2,E4) + kcalloc(E1*E2,sizeof(E3),E4) @@ expression E1,E2,E3; type T; @@ - kzalloc(sizeof(T)*E1*E2,E3) + kcalloc(E1*E2,sizeof(T),E3) @@ constant E1; expression E2,E3; @@ - kzalloc(E1*E2,E3) + kcalloc(E1,E2,E3) Navya Sri Nizamkari (3): staging: wlan-ng: Use kzalloc instead of kmalloc. staging: rtl8192u: Use kzalloc instead of kmalloc. staging: rtl8192e: Use kzalloc instead of kmalloc. drivers/staging/rtl8192e/rtllib_softmac.c | 3 +-- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +-- drivers/staging/wlan-ng/hfa384x_usb.c | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) -- 1.9.1