iproute2: Fix warnings with gcc 4.9 and clang 3.4
Subsystems (2)
PATCH 1/1 iproute2: Fix warnings with gcc 4.9 and clang 3.4
Hi,
the latest compilers (gcc 4.9 and clang 3.4) issue warnings when doing an incomplete struct initialization (e.g. "struct tc_sizespec s = {0};").
Since many people like to compile lower level bits and pieces with -Werror, this should probably be fixed. Patch attached.
ttyl
bero
From: Bernhard Rosenkränzer <[email protected]>
Subject: [PATCH] Fix compiler warnings with gcc 4.9 and clang 3.4
Current compilers (gcc 4.9 and clang 3.4) issue warnings when doing an incomplete struct initialization (e.g. "struct tc_sizespec s = {0};").
Initialize the structs completely so we can build with -Werror.
---
tc/tc_stab.c +1 -1
@@ -124,7 +124,7 @@parse_rtattr_nested (tb,TCA_STAB_MAX , rta);if (tb[TCA_STAB_BASE ]) { -struct tc_sizespec s = {0 }; +struct tc_sizespec s = {0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 };memcpy (&s,RTA_DATA (tb[TCA_STAB_BASE ]),MIN (RTA_PAYLOAD (tb[TCA_STAB_BASE ]),sizeof (s)));
tc/tc_util.c +5 -5
@@ -139,7 +139,7 @@ { "GBps", 8000000000. }, { "TiBps", 8.*1024.*1024.*1024.*1024. }, { "TBps", 8000000000000. }, - { NULL } + { NULL, .0 } };
@@ -472,28 +472,28 @@parse_rtattr_nested (tbs,TCA_STATS_MAX , rta);if (tbs[TCA_STATS_BASIC ]) { -struct gnet_stats_basic bs = {0 }; +struct gnet_stats_basic bs = {0 ,0 };memcpy (&bs,RTA_DATA (tbs[TCA_STATS_BASIC ]),MIN (RTA_PAYLOAD (tbs[TCA_STATS_BASIC ]),sizeof (bs)));fprintf (fp,"%sSent %llu bytes %u pkt" , prefix, (unsigned long long ) bs.bytes, bs.packets); }if (tbs[TCA_STATS_QUEUE ]) { -struct gnet_stats_queue q = {0 }; +struct gnet_stats_queue q = {0 ,0 ,0 ,0 ,0 };memcpy (&q,RTA_DATA (tbs[TCA_STATS_QUEUE ]),MIN (RTA_PAYLOAD (tbs[TCA_STATS_QUEUE ]),sizeof (q)));fprintf (fp," (dropped %u, overlimits %u requeues %u) " , q.drops, q.overlimits, q.requeues); }if (tbs[TCA_STATS_RATE_EST ]) { -struct gnet_stats_rate_est re = {0 }; +struct gnet_stats_rate_est re = {0 ,0 };memcpy (&re,RTA_DATA (tbs[TCA_STATS_RATE_EST ]),MIN (RTA_PAYLOAD (tbs[TCA_STATS_RATE_EST ]),sizeof (re)));fprintf (fp,"\n%srate %s %upps " , prefix,sprint_rate (re.bps, b1), re.pps); }if (tbs[TCA_STATS_QUEUE ]) { -struct gnet_stats_queue q = {0 }; +struct gnet_stats_queue q = {0 ,0 ,0 ,0 ,0 };memcpy (&q,RTA_DATA (tbs[TCA_STATS_QUEUE ]),MIN (RTA_PAYLOAD (tbs[TCA_STATS_QUEUE ]),sizeof (q)));if (!tbs[TCA_STATS_RATE_EST ])fprintf (fp,"\n%s" , prefix);
Quoted 10 lines · On Fri, 07 Mar 2014 03:00:53 +0100 Bernhard Rosenkränzer <[email protected]> wrote:
Hi,
the latest compilers (gcc 4.9 and clang 3.4) issue warnings when doing an incomplete struct initialization (e.g. "structtc_sizespecs = {0};").Since many people like to compile lower level bits and pieces with -Werror, this should probably be fixed. Patch attached.
ttyl
bero
Does not apply to current source, please update:
Quoted 4 lines · Bernhard Rosenkränzer
Hi,
the latest compilers (gcc 4.9 and clang 3.4) issue warnings when doing an incomplete struct initialization (e.g. "structtc_sizespecs = {0};").Since many people like to compile lower level bits and pieces with -Werror, this should probably be fixed. Patch attached.
Sounds like newer compilers are reverting:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
Hopefully not.
thanks,
Pádraig.