netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Bernhard Rosenkränzer" <bero@lindev.ch>
To: netdev@vger.kernel.org
Subject: [PATCH] iproute2: Fix warnings with gcc 4.9 and clang 3.4
Date: Fri, 07 Mar 2014 03:00:53 +0100	[thread overview]
Message-ID: <284875ac93e0904c42a436cbf05cc57d@mail.lindev.ch> (raw)

[-- Attachment #1: Type: text/plain, Size: 286 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: iproute2-compilerwarnings.patch --]
[-- Type: text/x-diff; name=iproute2-compilerwarnings.patch, Size: 2357 bytes --]

From: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
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.

Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
---

diff --git a/tc/tc_stab.c b/tc/tc_stab.c
index 47b4e5e..7407ce5 100644
--- a/tc/tc_stab.c
+++ b/tc/tc_stab.c
@@ -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)));
 
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 926ed08..548b728 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -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);

             reply	other threads:[~2014-03-07  2:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07  2:00 Bernhard Rosenkränzer [this message]
2014-03-10 20:25 ` [PATCH] iproute2: Fix warnings with gcc 4.9 and clang 3.4 Stephen Hemminger
2014-03-11  3:30 ` Pádraig Brady

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=284875ac93e0904c42a436cbf05cc57d@mail.lindev.ch \
    --to=bero@lindev.ch \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).