netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Reorder initialization in ip_route_output to fix gcc warning
@ 2012-06-11  6:05 Roland Dreier
  2012-06-11  6:44 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2012-06-11  6:05 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Roland Dreier

From: Roland Dreier <roland@purestorage.com>

If I build with W=1, for every file that includes <net/route.h>, I get the warning

    include/net/route.h: In function 'ip_route_output':
    include/net/route.h:135:3: warning: initialized field overwritten [-Woverride-init]
    include/net/route.h:135:3: warning: (near initialization for 'fl4') [-Woverride-init]

(This is with "gcc (Debian 4.6.3-1) 4.6.3")

A fix seems pretty trivial: move the initialization of .flowi4_tos
earlier.  As far as I can tell, this has no effect on code generation.

Signed-off-by: Roland Dreier <roland@purestorage.com>
---
 include/net/route.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/route.h b/include/net/route.h
index ed2b78e..9870546 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -130,9 +130,9 @@ static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
 {
 	struct flowi4 fl4 = {
 		.flowi4_oif = oif,
+		.flowi4_tos = tos,
 		.daddr = daddr,
 		.saddr = saddr,
-		.flowi4_tos = tos,
 	};
 	return ip_route_output_key(net, &fl4);
 }
-- 
1.7.9.5

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

* Re: [PATCH] net: Reorder initialization in ip_route_output to fix gcc warning
  2012-06-11  6:05 [PATCH] net: Reorder initialization in ip_route_output to fix gcc warning Roland Dreier
@ 2012-06-11  6:44 ` David Miller
  2012-06-11  7:00   ` Roland Dreier
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2012-06-11  6:44 UTC (permalink / raw)
  To: roland; +Cc: netdev, roland

From: Roland Dreier <roland@kernel.org>
Date: Sun, 10 Jun 2012 23:05:24 -0700

> From: Roland Dreier <roland@purestorage.com>
> 
> If I build with W=1, for every file that includes <net/route.h>, I get the warning
> 
>     include/net/route.h: In function 'ip_route_output':
>     include/net/route.h:135:3: warning: initialized field overwritten [-Woverride-init]
>     include/net/route.h:135:3: warning: (near initialization for 'fl4') [-Woverride-init]
> 
> (This is with "gcc (Debian 4.6.3-1) 4.6.3")
> 
> A fix seems pretty trivial: move the initialization of .flowi4_tos
> earlier.  As far as I can tell, this has no effect on code generation.
> 
> Signed-off-by: Roland Dreier <roland@purestorage.com>

I can't figure out what it is actually warning about, can you?

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

* Re: [PATCH] net: Reorder initialization in ip_route_output to fix gcc warning
  2012-06-11  6:44 ` David Miller
@ 2012-06-11  7:00   ` Roland Dreier
  2012-06-11  7:05     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Dreier @ 2012-06-11  7:00 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

> I can't figure out what it is actually warning about, can you?

I think gcc thinks it already initialized the __fl_common struct
once when it hits the .flowi4_oif initializer (which expands to
__fl_common.flowic_oif), and then having the .daddr / .saddr
initializers makes it thinks its done with that structure.

So it thinks it's initializing __fl_common.flowic_tos to 0, and
then the .flowi4_tos initializer comes along as a surprise.

Hmm, looks like http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52880
which is fixed after gcc 4.7.0.  I think it's probably worth working
around this gcc issue, since this makes W=1 way noisier in
my build.

 - R.

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

* Re: [PATCH] net: Reorder initialization in ip_route_output to fix gcc warning
  2012-06-11  7:00   ` Roland Dreier
@ 2012-06-11  7:05     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2012-06-11  7:05 UTC (permalink / raw)
  To: roland; +Cc: netdev

From: Roland Dreier <roland@kernel.org>
Date: Mon, 11 Jun 2012 00:00:51 -0700

>> I can't figure out what it is actually warning about, can you?
> 
> I think gcc thinks it already initialized the __fl_common struct
> once when it hits the .flowi4_oif initializer (which expands to
> __fl_common.flowic_oif), and then having the .daddr / .saddr
> initializers makes it thinks its done with that structure.
> 
> So it thinks it's initializing __fl_common.flowic_tos to 0, and
> then the .flowi4_tos initializer comes along as a surprise.
> 
> Hmm, looks like http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52880
> which is fixed after gcc 4.7.0.  I think it's probably worth working
> around this gcc issue, since this makes W=1 way noisier in
> my build.

I suspected it was a compiler bug :-)

Anyways, agreed, applied.

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

end of thread, other threads:[~2012-06-11  7:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-11  6:05 [PATCH] net: Reorder initialization in ip_route_output to fix gcc warning Roland Dreier
2012-06-11  6:44 ` David Miller
2012-06-11  7:00   ` Roland Dreier
2012-06-11  7:05     ` David Miller

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).