kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [KJ] [Patch] kzalloc() conversion in  lib/
@ 2006-03-05  8:41 Eric Sesterhenn
  2006-03-05 17:58 ` Alexey Dobriyan
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Eric Sesterhenn @ 2006-03-05  8:41 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1583 bytes --]

hi, 

this patch converts lib/ to kzalloc usage.
Compile tested with allyesconfig.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/lib/genalloc.c.orig	2006-03-04 21:55:53.000000000 +0100
+++ linux-2.6.16-rc5-mm1/lib/genalloc.c	2006-03-04 21:57:03.000000000 +0100
@@ -47,20 +47,17 @@ struct gen_pool *gen_pool_create(int nr_
 	if (!max_chunk_shift)
 		max_chunk_shift = PAGE_SHIFT;
 
-	poolp = kmalloc(sizeof(struct gen_pool), GFP_KERNEL);
+	poolp = kzalloc(sizeof(struct gen_pool), GFP_KERNEL);
 	if (!poolp)
 		return NULL;
-	memset(poolp, 0, sizeof(struct gen_pool));
-	poolp->h = kmalloc(sizeof(struct gen_pool_link) *
-			   (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
-			   GFP_KERNEL);
+	poolp->h = kcalloc((max_chunk_shift - ALLOC_MIN_SHIFT + ),
+				sizeof(struct gen_pool_link), 
+				GFP_KERNEL);
 	if (!poolp->h) {
 		printk(KERN_WARNING "gen_pool_alloc() failed to allocate\n");
 		kfree(poolp);
 		return NULL;
 	}
-	memset(poolp->h, 0, sizeof(struct gen_pool_link) *
-	       (max_chunk_shift - ALLOC_MIN_SHIFT + 1));
 
 	spin_lock_init(&poolp->lock);
 	poolp->get_new_chunk = fp;
--- linux-2.6.16-rc5-mm1/lib/kobject.c.orig	2006-03-04 21:57:14.000000000 +0100
+++ linux-2.6.16-rc5-mm1/lib/kobject.c	2006-03-04 21:57:23.000000000 +0100
@@ -111,10 +111,9 @@ char *kobject_get_path(struct kobject *k
 	len = get_kobj_path_length(kobj);
 	if (len == 0)
 		return NULL;
-	path = kmalloc(len, gfp_mask);
+	path = kzalloc(len, gfp_mask);
 	if (!path)
 		return NULL;
-	memset(path, 0x00, len);
 	fill_kobj_path(kobj, path, len);
 
 	return path;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in  lib/
  2006-03-05  8:41 [KJ] [Patch] kzalloc() conversion in lib/ Eric Sesterhenn
@ 2006-03-05 17:58 ` Alexey Dobriyan
  2006-03-05 20:43 ` Jaco Kroon
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Alexey Dobriyan @ 2006-03-05 17:58 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]

On Sun, Mar 05, 2006 at 09:41:37AM +0100, Eric Sesterhenn wrote:
> this patch converts lib/ to kzalloc usage.
> Compile tested with allyesconfig.

> --- linux-2.6.16-rc5-mm1/lib/genalloc.c.orig
> +++ linux-2.6.16-rc5-mm1/lib/genalloc.c
> @@ -47,20 +47,17 @@ struct gen_pool *gen_pool_create(int nr_
>  	if (!max_chunk_shift)
>  		max_chunk_shift = PAGE_SHIFT;
>
> -	poolp = kmalloc(sizeof(struct gen_pool), GFP_KERNEL);
> +	poolp = kzalloc(sizeof(struct gen_pool), GFP_KERNEL);
>  	if (!poolp)
>  		return NULL;
> -	memset(poolp, 0, sizeof(struct gen_pool));
> -	poolp->h = kmalloc(sizeof(struct gen_pool_link) *
> -			   (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
> -			   GFP_KERNEL);
> +	poolp->h = kcalloc((max_chunk_shift - ALLOC_MIN_SHIFT + ),

This will screw ia64.

> +				sizeof(struct gen_pool_link),
> +				GFP_KERNEL);
>  	if (!poolp->h) {
>  		printk(KERN_WARNING "gen_pool_alloc() failed to allocate\n");
>  		kfree(poolp);
>  		return NULL;
>  	}
> -	memset(poolp->h, 0, sizeof(struct gen_pool_link) *
> -	       (max_chunk_shift - ALLOC_MIN_SHIFT + 1));


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in  lib/
  2006-03-05  8:41 [KJ] [Patch] kzalloc() conversion in lib/ Eric Sesterhenn
  2006-03-05 17:58 ` Alexey Dobriyan
@ 2006-03-05 20:43 ` Jaco Kroon
  2006-03-05 20:50 ` Eric Sesterhenn
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jaco Kroon @ 2006-03-05 20:43 UTC (permalink / raw)
  To: kernel-janitors


[-- Attachment #1.1: Type: text/plain, Size: 919 bytes --]

Alexey Dobriyan wrote:
> On Sun, Mar 05, 2006 at 09:41:37AM +0100, Eric Sesterhenn wrote:
> 
>>this patch converts lib/ to kzalloc usage.
>>Compile tested with allyesconfig.

>> 	if (!poolp)
>> 		return NULL;
>>-	memset(poolp, 0, sizeof(struct gen_pool));
>>-	poolp->h = kmalloc(sizeof(struct gen_pool_link) *
>>-			   (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
>>-			   GFP_KERNEL);
>>+	poolp->h = kcalloc((max_chunk_shift - ALLOC_MIN_SHIFT + ),
> 
> 
> This will screw ia64.
> 

I don't see how it would even compile in the first place.  But would you
mind explaining how this would screw ia64?

> 
>>+				sizeof(struct gen_pool_link),
>>+				GFP_KERNEL);
>> 	if (!poolp->h) {
>> 		printk(KERN_WARNING "gen_pool_alloc() failed to allocate\n");
>> 		kfree(poolp);
>> 		return NULL;
>> 	}


-- 
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/

[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3233 bytes --]

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in  lib/
  2006-03-05  8:41 [KJ] [Patch] kzalloc() conversion in lib/ Eric Sesterhenn
  2006-03-05 17:58 ` Alexey Dobriyan
  2006-03-05 20:43 ` Jaco Kroon
@ 2006-03-05 20:50 ` Eric Sesterhenn
  2006-03-05 20:55 ` Eric Sesterhenn
  2006-03-05 21:09 ` Jaco Kroon
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 20:50 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 275 bytes --]

hi,
> > This will screw ia64.
> > 
> 
> I don't see how it would even compile in the first place.  But would you
> mind explaining how this would screw ia64?

thats why it would screw ia64. It seems to not get compiled on i386,
thats why my "make lib/" didnt catch it

Eric


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in  lib/
  2006-03-05  8:41 [KJ] [Patch] kzalloc() conversion in lib/ Eric Sesterhenn
                   ` (2 preceding siblings ...)
  2006-03-05 20:50 ` Eric Sesterhenn
@ 2006-03-05 20:55 ` Eric Sesterhenn
  2006-03-05 21:09 ` Jaco Kroon
  4 siblings, 0 replies; 6+ messages in thread
From: Eric Sesterhenn @ 2006-03-05 20:55 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2309 bytes --]

hi,

> > --- linux-2.6.16-rc5-mm1/lib/genalloc.c.orig
> > +++ linux-2.6.16-rc5-mm1/lib/genalloc.c
> > @@ -47,20 +47,17 @@ struct gen_pool *gen_pool_create(int nr_
> >  	if (!max_chunk_shift)
> >  		max_chunk_shift = PAGE_SHIFT;
> >
> > -	poolp = kmalloc(sizeof(struct gen_pool), GFP_KERNEL);
> > +	poolp = kzalloc(sizeof(struct gen_pool), GFP_KERNEL);
> >  	if (!poolp)
> >  		return NULL;
> > -	memset(poolp, 0, sizeof(struct gen_pool));
> > -	poolp->h = kmalloc(sizeof(struct gen_pool_link) *
> > -			   (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
> > -			   GFP_KERNEL);
> > +	poolp->h = kcalloc((max_chunk_shift - ALLOC_MIN_SHIFT + ),
> 
> This will screw ia64.

attached patch below. Is there something like a cross compiler live cd,
so one can put time where concentration is missing to catch such stuff?

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc5-mm1/lib/genalloc.c.orig	2006-03-04 21:55:53.000000000 +0100
+++ linux-2.6.16-rc5-mm1/lib/genalloc.c	2006-03-04 21:57:03.000000000 +0100
@@ -47,20 +47,17 @@ struct gen_pool *gen_pool_create(int nr_
 	if (!max_chunk_shift)
 		max_chunk_shift = PAGE_SHIFT;
 
-	poolp = kmalloc(sizeof(struct gen_pool), GFP_KERNEL);
+	poolp = kzalloc(sizeof(struct gen_pool), GFP_KERNEL);
 	if (!poolp)
 		return NULL;
-	memset(poolp, 0, sizeof(struct gen_pool));
-	poolp->h = kmalloc(sizeof(struct gen_pool_link) *
-			   (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
-			   GFP_KERNEL);
+	poolp->h = kcalloc((max_chunk_shift - ALLOC_MIN_SHIFT + 1),
+				sizeof(struct gen_pool_link), 
+				GFP_KERNEL);
 	if (!poolp->h) {
 		printk(KERN_WARNING "gen_pool_alloc() failed to allocate\n");
 		kfree(poolp);
 		return NULL;
 	}
-	memset(poolp->h, 0, sizeof(struct gen_pool_link) *
-	       (max_chunk_shift - ALLOC_MIN_SHIFT + 1));
 
 	spin_lock_init(&poolp->lock);
 	poolp->get_new_chunk = fp;
--- linux-2.6.16-rc5-mm1/lib/kobject.c.orig	2006-03-04 21:57:14.000000000 +0100
+++ linux-2.6.16-rc5-mm1/lib/kobject.c	2006-03-04 21:57:23.000000000 +0100
@@ -111,10 +111,9 @@ char *kobject_get_path(struct kobject *k
 	len = get_kobj_path_length(kobj);
 	if (len == 0)
 		return NULL;
-	path = kmalloc(len, gfp_mask);
+	path = kzalloc(len, gfp_mask);
 	if (!path)
 		return NULL;
-	memset(path, 0x00, len);
 	fill_kobj_path(kobj, path, len);
 
 	return path;



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KJ] [Patch] kzalloc() conversion in  lib/
  2006-03-05  8:41 [KJ] [Patch] kzalloc() conversion in lib/ Eric Sesterhenn
                   ` (3 preceding siblings ...)
  2006-03-05 20:55 ` Eric Sesterhenn
@ 2006-03-05 21:09 ` Jaco Kroon
  4 siblings, 0 replies; 6+ messages in thread
From: Jaco Kroon @ 2006-03-05 21:09 UTC (permalink / raw)
  To: kernel-janitors


[-- Attachment #1.1: Type: text/plain, Size: 1570 bytes --]

Eric Sesterhenn wrote:
> hi,
> 
> 
>>>--- linux-2.6.16-rc5-mm1/lib/genalloc.c.orig
>>>+++ linux-2.6.16-rc5-mm1/lib/genalloc.c
>>>@@ -47,20 +47,17 @@ struct gen_pool *gen_pool_create(int nr_
>>> 	if (!max_chunk_shift)
>>> 		max_chunk_shift = PAGE_SHIFT;
>>>
>>>-	poolp = kmalloc(sizeof(struct gen_pool), GFP_KERNEL);
>>>+	poolp = kzalloc(sizeof(struct gen_pool), GFP_KERNEL);
>>> 	if (!poolp)
>>> 		return NULL;
>>>-	memset(poolp, 0, sizeof(struct gen_pool));
>>>-	poolp->h = kmalloc(sizeof(struct gen_pool_link) *
>>>-			   (max_chunk_shift - ALLOC_MIN_SHIFT + 1),
>>>-			   GFP_KERNEL);
>>>+	poolp->h = kcalloc((max_chunk_shift - ALLOC_MIN_SHIFT + ),
>>
>>This will screw ia64.
> 
> attached patch below. Is there something like a cross compiler live cd,
> so one can put time where concentration is missing to catch such stuff?

Why would you need a cross-compiler live cd?  I've used the Gentoo
crossdev package on Friday to build cross-compilers on my system for
other architectures which would allow you to pass two flags to the
kernel build process, for example:

$ make ARCH=ia64 CROSS_COMPILE=x86_64-pc-linux-gnu- allyesconfig
$ make ARCH=ia64 CROSS_COMPILE=x86_64-pc-linux-gnu-

to build for ia64, or to build for armeb:

$ make ARCH=arm CROSS_COMPILE=armeb-unknown-linux-gnu- ixdp2801_defconfig
$ make ARCH=arm CROSS_COMPILE=armeb-unknown-linux-gnu-

And so forth.  This of course assumes that the required compilers exist.

Jaco
-- 
There are only 10 kinds of people in this world,
  those that understand binary and those that don't.
http://www.kroon.co.za/

[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3233 bytes --]

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-05 21:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-05  8:41 [KJ] [Patch] kzalloc() conversion in lib/ Eric Sesterhenn
2006-03-05 17:58 ` Alexey Dobriyan
2006-03-05 20:43 ` Jaco Kroon
2006-03-05 20:50 ` Eric Sesterhenn
2006-03-05 20:55 ` Eric Sesterhenn
2006-03-05 21:09 ` Jaco Kroon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).