GCC4 cleanup question
Hi,
I was wondering how would you fix warnings like the following:
net/ipv4/route.c: In function 'ip_route_input_slow':net/ipv4/route.c:1770: warning: 'rth' may be used uninitialized in this functionnet/ipv4/route.c:1797: warning: 'rth' may be used uninitialized in this functionnet/ipv4/route.c: In function 'ip_route_output_slow':net/ipv4/route.c:2270: warning: 'rth' may be used uninitialized in this functionnet/ipv4/route.c:2242: warning: 'rth' may be used uninitialized in this function
Thanks
chuck
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 12 lines · Chuck Short
Hi,
I was wondering how would you fix warnings like the following:
net/ipv4/route.c: In function 'ip_route_input_slow':net/ipv4/route.c:1770: warning: 'rth' may be used uninitialized in thisfunctionnet/ipv4/route.c:1797: warning: 'rth' may be used uninitialized in thisfunctionnet/ipv4/route.c: In function 'ip_route_output_slow':net/ipv4/route.c:2270: warning: 'rth' may be used uninitialized in thisfunctionnet/ipv4/route.c:2242: warning: 'rth' may be used uninitialized in this function
Quoted 2 lines
Thanks
chuck
I don't have GCC4, the first rth is initialised inside the __mkroute_input function and the second one is initialised in the __mkroute_output function. I don't know why gcc is giving those warings.
ipv4/route.c 2005-05-28 08:23:18.000000000 +0200 renamed from ipv4/route.c.old 2005-05-18 21:18:19.000000000 +0200 +2 -2
@@ -1767,7 +1767,7 @@ static inline int ip_mkroute_input_def(s struct in_device *in_dev, u32 daddr, u32 saddr, u32 tos) { - struct rtable* rth; + struct rtable* rth = NULL; int err; unsigned hash;
@@ -2267,7 +2267,7 @@ static inline int ip_mkroute_output(stru unsigned char hop; unsigned hash; int err = -EINVAL; - struct rtable *rth; + struct rtable *rth = NULL; if (res->fi && res->fi->fib_nhs > 1) { unsigned char hopcount = res->fi->fib_nhs;
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoting Bongani Hlope <[email protected]>
Sent on Sat, 28 May 2005 08:25:54 +0200
Quoted 3 lines
I don't have GCC4, the first rth is initialised inside the
__mkroute_inputfunction and the second one is initialised in the__mkroute_outputfunction. I don't know why gcc is giving those warings.
My guess is because it doesn't know/see that. Wouldn't that be related to the new interprocedural optimization?
More info, perhaps starting on:
http://gcc.gnu.org/wiki/Interprocedural%20optimizations
Signature · 6 lines
Ricardo Nabinger Sanchez
GNU/Linux #140696 [http://counter.li.org]
Slackware Linux + FreeBSD
How long a minute is depends on which
side of the bathroom door you're on._______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 3 lines · Bongani Hlope
I don't have GCC4, the first rth is initialised inside the
__mkroute_inputfunction and the second one is initialised in the__mkroute_outputfunction. I don't know why gcc is giving those warings.
__mkroute_{in,out}put does not initialize *result if it returns early.
ipv4/route.c 2005-05-28 08:23:18.000000000 +0200 static inline int ip_mkroute_input_def(s · line 1773
Quoted 11 lines
ipv4/route.c 2005-05-28 08:23:18.000000000 +0200 renamed from ipv4/route.c.old 2005-05-18 21:18:19.000000000 +0200 +1
-1@@ -1767,7 +1767,7 @@ static inline int ip_mkroute_input_def(s struct in_device *in_dev, u32 daddr, u32 saddr, u32 tos) { - struct rtable* rth; + struct rtable* rth = NULL; int err; unsigned hash;
We've already had that discussion. Don't initialize it to a bogus value in the declaration, but make sure it always gets set in the function that is responsible for initializing it (__mkroute_input in this case).
Arnd <><
_______________________________________________
Kernel-janitors mailing list
[email protected]
http://lists.osdl.org/mailman/listinfo/kernel-janitors