* [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
@ 2014-10-07 20:16 Fabian Frederick
2014-10-07 20:18 ` David Miller
0 siblings, 1 reply; 11+ messages in thread
From: Fabian Frederick @ 2014-10-07 20:16 UTC (permalink / raw)
To: linux-kernel; +Cc: Fabian Frederick, David S. Miller, netdev
static values are automatically initialized to NULL
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
net/unix/garbage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/unix/garbage.c b/net/unix/garbage.c
index 9bc73f8..99f7012 100644
--- a/net/unix/garbage.c
+++ b/net/unix/garbage.c
@@ -258,7 +258,7 @@ static void inc_inflight_move_tail(struct unix_sock *u)
list_move_tail(&u->link, &gc_candidates);
}
-static bool gc_in_progress = false;
+static bool gc_in_progress;
#define UNIX_INFLIGHT_TRIGGER_GC 16000
void wait_for_unix_gc(void)
--
1.9.3
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:16 [PATCH 1/1 net-next] af_unix: remove NULL assignment on static Fabian Frederick
@ 2014-10-07 20:18 ` David Miller
2014-10-07 20:26 ` Hannes Frederic Sowa
2014-10-07 20:33 ` Guenter Roeck
0 siblings, 2 replies; 11+ messages in thread
From: David Miller @ 2014-10-07 20:18 UTC (permalink / raw)
To: fabf; +Cc: linux-kernel, netdev
From: Fabian Frederick <fabf@skynet.be>
Date: Tue, 7 Oct 2014 22:16:36 +0200
> static values are automatically initialized to NULL
>
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
Isn't there some implementation room given to compilers
as to the representation of true and false?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:18 ` David Miller
@ 2014-10-07 20:26 ` Hannes Frederic Sowa
2014-10-07 20:33 ` Guenter Roeck
1 sibling, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-07 20:26 UTC (permalink / raw)
To: David Miller; +Cc: fabf, linux-kernel, netdev
On Di, 2014-10-07 at 16:18 -0400, David Miller wrote:
> From: Fabian Frederick <fabf@skynet.be>
> Date: Tue, 7 Oct 2014 22:16:36 +0200
>
> > static values are automatically initialized to NULL
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
>
> Isn't there some implementation room given to compilers
> as to the representation of true and false?
No, the standard requests implementations to implement false as 0 and
true as 1.
In case of assignments e.g. INT_MAX to _Bool (=bool) it will implicitly
converted to 1, so one can omit the often used !! with booleans.
Bye,
Hannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:18 ` David Miller
2014-10-07 20:26 ` Hannes Frederic Sowa
@ 2014-10-07 20:33 ` Guenter Roeck
2014-10-07 20:49 ` Fabian Frederick
1 sibling, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2014-10-07 20:33 UTC (permalink / raw)
To: David Miller; +Cc: fabf, linux-kernel, netdev
On Tue, Oct 07, 2014 at 04:18:32PM -0400, David Miller wrote:
> From: Fabian Frederick <fabf@skynet.be>
> Date: Tue, 7 Oct 2014 22:16:36 +0200
>
> > static values are automatically initialized to NULL
> >
> > Signed-off-by: Fabian Frederick <fabf@skynet.be>
>
> Isn't there some implementation room given to compilers
> as to the representation of true and false?
Not for true/false.
C99 standard, section 7.16:
...
The remaining three macros are suitable for use in #if preprocessing
directives. They are
true
which expands to the integer constant 1,
false
which expands to the integer constant 0, and
...
No idea where the NULL comes into the picture, though.
Guenter
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:33 ` Guenter Roeck
@ 2014-10-07 20:49 ` Fabian Frederick
2014-10-07 20:50 ` David Miller
2014-10-07 20:54 ` Hannes Frederic Sowa
0 siblings, 2 replies; 11+ messages in thread
From: Fabian Frederick @ 2014-10-07 20:49 UTC (permalink / raw)
To: Guenter Roeck, David Miller; +Cc: netdev, linux-kernel
> On 07 October 2014 at 22:33 Guenter Roeck <linux@roeck-us.net> wrote:
>
>
> On Tue, Oct 07, 2014 at 04:18:32PM -0400, David Miller wrote:
> > From: Fabian Frederick <fabf@skynet.be>
> > Date: Tue, 7 Oct 2014 22:16:36 +0200
> >
> > > static values are automatically initialized to NULL
> > >
> > > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> >
> > Isn't there some implementation room given to compilers
> > as to the representation of true and false?
>
> Not for true/false.
>
> C99 standard, section 7.16:
>
> ...
> The remaining three macros are suitable for use in #if preprocessing
> directives. They are
>
> true
>
> which expands to the integer constant 1,
>
> false
>
> which expands to the integer constant 0, and
> ...
>
> No idea where the NULL comes into the picture, though.
>
> Guenter
Maybe comment should have been "static values are automatically initialized to
0" then ?
Regards,
Fabian
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:49 ` Fabian Frederick
@ 2014-10-07 20:50 ` David Miller
2014-10-07 20:54 ` Hannes Frederic Sowa
1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2014-10-07 20:50 UTC (permalink / raw)
To: fabf; +Cc: linux, netdev, linux-kernel
From: Fabian Frederick <fabf@skynet.be>
Date: Tue, 7 Oct 2014 22:49:31 +0200 (CEST)
> Maybe comment should have been "static values are automatically initialized to
> 0" then ?
Yes, that sounds a lot better, please respin.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:49 ` Fabian Frederick
2014-10-07 20:50 ` David Miller
@ 2014-10-07 20:54 ` Hannes Frederic Sowa
2014-10-07 21:05 ` Fabian Frederick
2014-10-08 9:10 ` David Laight
1 sibling, 2 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-07 20:54 UTC (permalink / raw)
To: Fabian Frederick; +Cc: Guenter Roeck, David Miller, netdev, linux-kernel
On Di, 2014-10-07 at 22:49 +0200, Fabian Frederick wrote:
>
> > On 07 October 2014 at 22:33 Guenter Roeck <linux@roeck-us.net> wrote:
> >
> >
> > On Tue, Oct 07, 2014 at 04:18:32PM -0400, David Miller wrote:
> > > From: Fabian Frederick <fabf@skynet.be>
> > > Date: Tue, 7 Oct 2014 22:16:36 +0200
> > >
> > > > static values are automatically initialized to NULL
> > > >
> > > > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > >
> > > Isn't there some implementation room given to compilers
> > > as to the representation of true and false?
> >
> > Not for true/false.
> >
> > C99 standard, section 7.16:
> >
> > ...
> > The remaining three macros are suitable for use in #if preprocessing
> > directives. They are
> >
> > true
> >
> > which expands to the integer constant 1,
> >
> > false
> >
> > which expands to the integer constant 0, and
> > ...
> >
> > No idea where the NULL comes into the picture, though.
> >
> > Guenter
>
> Maybe comment should have been "static values are automatically initialized to
> 0" then ?
I think David's concern was whether if 0 == false in all situations. It
is pretty clear that static memory is initialized to 0.
Thanks,
Hannes
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:54 ` Hannes Frederic Sowa
@ 2014-10-07 21:05 ` Fabian Frederick
2014-10-08 9:10 ` David Laight
1 sibling, 0 replies; 11+ messages in thread
From: Fabian Frederick @ 2014-10-07 21:05 UTC (permalink / raw)
To: Hannes Frederic Sowa; +Cc: netdev, linux-kernel, Guenter Roeck, David Miller
> On 07 October 2014 at 22:54 Hannes Frederic Sowa <hannes@stressinduktion.org>
> wrote:
>
>
> On Di, 2014-10-07 at 22:49 +0200, Fabian Frederick wrote:
> >
> > > On 07 October 2014 at 22:33 Guenter Roeck <linux@roeck-us.net> wrote:
> > >
> > >
> > > On Tue, Oct 07, 2014 at 04:18:32PM -0400, David Miller wrote:
> > > > From: Fabian Frederick <fabf@skynet.be>
> > > > Date: Tue, 7 Oct 2014 22:16:36 +0200
> > > >
> > > > > static values are automatically initialized to NULL
> > > > >
> > > > > Signed-off-by: Fabian Frederick <fabf@skynet.be>
> > > >
> > > > Isn't there some implementation room given to compilers
> > > > as to the representation of true and false?
> > >
> > > Not for true/false.
> > >
> > > C99 standard, section 7.16:
> > >
> > > ...
> > > The remaining three macros are suitable for use in #if preprocessing
> > > directives. They are
> > >
> > > true
> > >
> > > which expands to the integer constant 1,
> > >
> > > false
> > >
> > > which expands to the integer constant 0, and
> > > ...
> > >
> > > No idea where the NULL comes into the picture, though.
> > >
> > > Guenter
> >
> > Maybe comment should have been "static values are automatically initialized
> > to
> > 0" then ?
>
> I think David's concern was whether if 0 == false in all situations. It
> is pretty clear that static memory is initialized to 0.
>
> Thanks,
> Hannes
Of course :) It was an answer to Guenter's explanation.
Regards,
Fabian
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-07 20:54 ` Hannes Frederic Sowa
2014-10-07 21:05 ` Fabian Frederick
@ 2014-10-08 9:10 ` David Laight
2014-10-08 9:34 ` Hannes Frederic Sowa
2014-10-08 9:46 ` Michal Kubecek
1 sibling, 2 replies; 11+ messages in thread
From: David Laight @ 2014-10-08 9:10 UTC (permalink / raw)
To: 'Hannes Frederic Sowa', Fabian Frederick
Cc: Guenter Roeck, David Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
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.
If NULL isn't the 'all 0 bit pattern' then the memory would need
to be initialised to a different pattern.
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.
David
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-08 9:10 ` David Laight
@ 2014-10-08 9:34 ` Hannes Frederic Sowa
2014-10-08 9:46 ` Michal Kubecek
1 sibling, 0 replies; 11+ messages in thread
From: Hannes Frederic Sowa @ 2014-10-08 9:34 UTC (permalink / raw)
To: David Laight
Cc: Fabian Frederick, Guenter Roeck, David Miller,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/1 net-next] af_unix: remove NULL assignment on static
2014-10-08 9:10 ` David Laight
2014-10-08 9:34 ` Hannes Frederic Sowa
@ 2014-10-08 9:46 ` Michal Kubecek
1 sibling, 0 replies; 11+ messages in thread
From: Michal Kubecek @ 2014-10-08 9:46 UTC (permalink / raw)
To: David Laight
Cc: 'Hannes Frederic Sowa', Fabian Frederick, Guenter Roeck,
David Miller, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
On Wed, Oct 08, 2014 at 09:10:23AM +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.
ISO C 99 says:
If an object that has static storage duration is not initialized
explicitly, then:
- if it has pointer type, it is initialized to a null pointer;
- if it has arithmetic type, it is initialized to (positive or
unsigned) zero;
- if it is an aggregate, every member is initialized (recursively)
according to these rules;
- if it is a union, the first named member is initialized
(recursively) according to these rules.
Michal Kubeček
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-10-08 9:46 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-07 20:16 [PATCH 1/1 net-next] af_unix: remove NULL assignment on static Fabian Frederick
2014-10-07 20:18 ` David Miller
2014-10-07 20:26 ` Hannes Frederic Sowa
2014-10-07 20:33 ` Guenter Roeck
2014-10-07 20:49 ` Fabian Frederick
2014-10-07 20:50 ` David Miller
2014-10-07 20:54 ` Hannes Frederic Sowa
2014-10-07 21:05 ` Fabian Frederick
2014-10-08 9:10 ` David Laight
2014-10-08 9:34 ` Hannes Frederic Sowa
2014-10-08 9:46 ` Michal Kubecek
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).