xfrm_hash: kmalloc + memset conversion to kzalloc
Subsystems (3)
PATCH 1/4 xfrm_hash: kmalloc + memset conversion to kzalloc
xfrm_hash: kmalloc + memset conversion to kzalloc
Thanks.
Joonwoo
---
net/xfrm/xfrm_hash.c +11 -10
@@ -17,16 +17,17 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz)struct hlist_head *n;if (sz <=PAGE_SIZE ) - n =kmalloc (sz,GFP_KERNEL ); -else if (hashdist) - n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL ); -else - n = (struct hlist_head *) -__get_free_pages (GFP_KERNEL | __GFP_NOWARN, -get_order (sz)); - -if (n) -memset (n,0 , sz); + n =kzalloc (sz,GFP_KERNEL ); +else { +if (hashdist) + n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL ); +else + n = (struct hlist_head *) +__get_free_pages (GFP_KERNEL | __GFP_NOWARN, +get_order (sz)); +if (n) +memset (n,0 , sz); + }return n; }
---
Quoted 19 lines · Joonwoo Park
xfrm_hash: kmalloc + memset conversion to kzallocSigned-off-by Joonwoo Park <[email protected]>Thanks.
Joonwoo---
net/xfrm/xfrm_hash.c +0
-3@@ -17,16 +17,17 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz)struct hlist_head *n;if (sz <=PAGE_SIZE ) - n =kmalloc (sz,GFP_KERNEL ); -else if (hashdist) - n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL );
net/xfrm/xfrm_hash.c struct hlist_head *xfrm_hash_alloc(unsigned int sz) · line 22
Quoted 10 lines
net/xfrm/xfrm_hash.c +3
-7-else - n = (struct hlist_head *) -__get_free_pages (GFP_KERNEL | __GFP_NOWARN, -get_order (sz)); - -if (n) -memset (n,0 , sz); + n =kzalloc (sz,GFP_KERNEL ); + else { +if (hashdist)
i believe the more common standard for the above is:
else if (hashdist) {to reduce the level of overall indentation, no?
rday
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================
Quoted 7 lines
i believe the more common standard for the above is:
else if (hashdist) {
to reduce the level of overall indentation, no?
No, it was.
Because there was a memset in that indentation, but I made it by removing memset.
Thanks.
Joonwoo
Quoted 18 lines · Joonwoo Park
net/xfrm/xfrm_hash.c +0
-10@@ -17,16 +17,17 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz)struct hlist_head *n;if (sz <=PAGE_SIZE ) - n =kmalloc (sz,GFP_KERNEL ); -else if (hashdist) - n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL ); -else - n = (struct hlist_head *) -__get_free_pages (GFP_KERNEL | __GFP_NOWARN, -get_order (sz)); - -if (n) -memset (n,0 , sz);
net/xfrm/xfrm_hash.c struct hlist_head *xfrm_hash_alloc(unsigned int sz) · line 29
Quoted 10 lines
net/xfrm/xfrm_hash.c +10
-0+ n =kzalloc (sz,GFP_KERNEL ); + else { +if (hashdist) + n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL ); +else + n = (struct hlist_head *) +__get_free_pages (GFP_KERNEL | __GFP_NOWARN, +get_order (sz)); +if (n) +memset (n,0 , sz);
How about also switching vmalloc/get_free_pages to GFP_ZERO and getting rid of the memset entirely while you're at it?
2007/11/26, Patrick McHardy <[email protected]>:
Quoted 3 lines
How about also switching vmalloc/get_free_pages to
GFP_ZEROand getting rid of the memset entirely while you're at it?
xfrm_hash: kmalloc + memset conversion to kzalloc
fix to avoid memset entirely.
Thanks Patrick.
Thanks.
Joonwoo
---
net/xfrm/xfrm_hash.c +3 -6
@@ -17,17 +17,14 @@ struct hlist_head *xfrm_hash_alloc(unsigned int sz)struct hlist_head *n;if (sz <=PAGE_SIZE ) - n =kmalloc (sz,GFP_KERNEL ); + n =kzalloc (sz,GFP_KERNEL );else if (hashdist) - n =__vmalloc (sz,GFP_KERNEL ,PAGE_KERNEL ); + n =__vmalloc (sz,GFP_KERNEL | __GFP_ZERO,PAGE_KERNEL );else n = (struct hlist_head *) -__get_free_pages (GFP_KERNEL | __GFP_NOWARN, +__get_free_pages (GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,get_order (sz)); -if (n) -memset (n,0 , sz); -return n; }
---
Herbert Xu
maintainerQuoted 7 lines · Joonwoo Park
2007/11/26, Patrick McHardy <[email protected]>:
Quoted 3 lines
How about also switching vmalloc/get_free_pages to
GFP_ZEROand getting rid of the memset entirely while you're at it?
xfrm_hash: kmalloc + memset conversion to kzalloc
fix to avoid memset entirely.
Patch applied. Thanks everyone!
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt