Re: kfree(0) - ok?

From: Giacomo A. Catenazzi
Date: Wed Aug 15 2007 - 05:32:22 EST


Jan Engelhardt wrote:
On Aug 14 2007 16:21, Jason Uhlenkott wrote:
On Tue, Aug 14, 2007 at 15:55:48 -0700, Arjan van de Ven wrote:
NULL is not 0 though.
It is. Its representation isn't guaranteed to be all-bits-zero,

C guarantees that.

Hmm. It depends on your interpretation of "representation".
On memory a null pointer can have some bit set.

No, see a very recent discussion on austin group list
(which list also few machines that don't have all 0-bits null pointer)

To clarify, from Rationale of C99, section 6.7.8 "Initialization":

: An implementation might conceivably have codes for floating zero
: and/or null pointer other than all bits zero. In such a case,
: the implementation must fill out an incomplete initializer with
: the various appropriate representations of zero; it may not just
: fill the area with zero bytes. As far as the committee knows,
: all machines treat all bits zero as a representation of
: floating-point zero. But, all bits zero might not be the
: canonical representation of zero.

Anyway, I think for kernel it is safe to assume all-zero bit
null pointer.

ciao
cate
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/