Re: kfree(0) - ok?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jan Engelhardt <jengelh@...>
Cc: Rene Herman <rene.herman@...>, Jason Uhlenkott <jasonuhl@...>, Arjan van de Ven <arjan@...>, Tim Bird <tim.bird@...>, linux kernel <linux-kernel@...>
Date: Wednesday, August 15, 2007 - 10:34 am

On Aug 15, 2007, at 10:06:49, Jan Engelhardt wrote:

Well, what I was referring to is:

static struct foo *some_ptr;

/* Assumes that $SOME_LOCK is held */
int initialize_foo_module()
{
	if (!some_ptr) {
		some_ptr = kmalloc(sizeof(*some_ptr));
		if (!some_ptr)
			return -ENOMEM;

		/* ... */
	}

	/* ... */
}


We initialize all of the static data to all-bits-clear zeros during  
kernel init.  Any platform on which the binary representations of  
"(unsigned long)0" and "(void *)0" are different (even in length, due  
to other issues) will not run the Linux kernel as it stands today.

And as to the sizeof(unsigned long) == sizeof(void *) issue, please  
remember that every Linux compiler is either ILP32 (int, long, and  
pointer are 32-bit) or LP64 (int is 32-bit and long/pointer are 64- 
bit).  We sort of fundamentally rely on these properties in code all  
over the place.

So yes the Linux kernel "breaks the standard" in a bunch of places,  
but on the other hand we're not your average software and we don't  
have to worry about building on an LLP64 compiler (Windows 64-bit and  
some UNIXes) or other strangeness.

Cheers,
Kyle Moffett

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kfree(0) - ok?, Tim Bird, (Tue Aug 14, 6:59 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Tue Aug 14, 7:13 pm)
Re: kfree(0) - ok?, Arjan van de Ven, (Tue Aug 14, 6:55 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Tue Aug 14, 7:42 pm)
Re: kfree(0) - ok?, Andrew Morton, (Fri Aug 17, 2:22 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Fri Aug 17, 5:13 pm)
Re: kfree(0) - ok?, Christoph Lameter, (Fri Aug 17, 5:14 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Fri Aug 17, 5:46 pm)
Re: kfree(0) - ok?, Pekka Enberg, (Fri Aug 17, 5:42 pm)
Re: kfree(0) - ok?, Thomas Gleixner, (Fri Aug 17, 7:40 pm)
Re: kfree(0) - ok?, Jan Engelhardt, (Sat Aug 18, 4:21 am)
Re: kfree(0) - ok?, Pekka Enberg, (Sat Aug 18, 4:10 am)
Re: kfree(0) - ok?, Christoph Lameter, (Fri Aug 17, 9:03 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Fri Aug 17, 8:02 pm)
Re: kfree(0) - ok?, Christoph Lameter, (Fri Aug 17, 7:22 pm)
Re: kfree(0) - ok?, Christoph Lameter, (Fri Aug 17, 4:43 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Fri Aug 17, 5:17 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Fri Aug 17, 5:32 pm)
Re: kfree(0) - ok?, Jan Engelhardt, (Fri Aug 17, 2:37 pm)
Re: kfree(0) - ok?, Arjan van de Ven, (Fri Aug 17, 2:31 pm)
Re: kfree(0) - ok?, Satyam Sharma, (Fri Aug 17, 2:50 pm)
Re: kfree(0) - ok?, Christoph Lameter, (Tue Aug 14, 8:19 pm)
Re: kfree(0) - ok?, Jason Uhlenkott, (Tue Aug 14, 7:21 pm)
Re: kfree(0) - ok?, Jan Engelhardt, (Wed Aug 15, 3:28 am)
Re: kfree(0) - ok?, Giacomo A. Catenazzi, (Wed Aug 15, 5:32 am)
Re: kfree(0) - ok?, Andreas Schwab, (Wed Aug 15, 5:18 am)
Re: kfree(0) - ok?, Jason Uhlenkott, (Wed Aug 15, 4:52 am)
Re: kfree(0) - ok?, Rene Herman, (Wed Aug 15, 4:37 am)
Re: kfree(0) - ok?, Jan Engelhardt, (Wed Aug 15, 5:20 am)
Re: kfree(0) - ok?, Rene Herman, (Wed Aug 15, 5:58 am)
Re: kfree(0) - ok?, Jan Engelhardt, (Wed Aug 15, 6:20 am)
Re: kfree(0) - ok?, H. Peter Anvin, (Wed Aug 15, 12:01 pm)
Re: kfree(0) - ok?, Kyle Moffett, (Wed Aug 15, 9:58 am)
Re: kfree(0) - ok?, Jan Engelhardt, (Wed Aug 15, 10:06 am)
Re: kfree(0) - ok?, Kyle Moffett, (Wed Aug 15, 10:34 am)
Re: kfree(0) - ok?, Rene Herman, (Wed Aug 15, 6:27 am)
Re: kfree(0) - ok?, Jason Uhlenkott, (Wed Aug 15, 5:43 am)