lkml.org 
[lkml]   [2014]   [Oct]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
From
Date
On Mi, 2014-10-08 at 09:10 +0000, David Laight wrote:
> From: Hannes Frederic Sowa
> > I think David's concern was whether if 0 == false in all situations. It
> > is pretty clear that static memory is initialized to 0.
>
> I'm not 100% sure about that.
> static pointers may be required to be initialised to NULL.

This isn't something the C standard specified but in case of Linux, I
think the ELF standard might be the right one to look at. Looking at the
kernel, I think this is an unwritten law. ;)

The standard allows NULL and static memory initialization to be
implementation defined, so NULL very well might not be 'all 0', that's
correct. Even static memory must only be initialized, when this happens
and how it is initialized is completely up to the implementation.

> If NULL isn't the 'all 0 bit pattern' then the memory would need
> to be initialised to a different pattern.

I haven't looked closely but I don't think that pointers need to be
initialized to NULL, but please don't quote me on this.

> Not that anyone is likely to implement such a system because far too
> much code will break.
>
> The only system I knew where 'native' NULL pointers were 'all 1s'
> used 0 in its C compiler.

:)

Bye,
Hannes




\
 
 \ /
  Last update: 2014-10-08 12:01    [W:0.050 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site