Skip to contentSkip to conversation

net: codel: fix build errors

PATCH Superseded Sasha Levin 4 participants 7 messages May 14, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: codel: fix build errors

Fix the following build error:

net/sched/sch_fq_codel.c: In function 'fq_codel_dump_stats':
net/sched/sch_fq_codel.c:464:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:464:3: warning: missing braces around initializer net/sched/sch_fq_codel.c:464:3: warning: (near initialization for 'st.<anonymous>') net/sched/sch_fq_codel.c:465:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:465:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:466:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:466:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:467:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:467:3: warning: (near initialization for 'st') make[1]: *** [net/sched/sch_fq_codel.o] Error 1

---
 include/linux/pkt_sched.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
include/linux/pkt_sched.h +3 -1
index 32aef0a..c304eda 100644
@@ -732,7 +732,9 @@ struct tc_fq_codel_xstats {
 	union {
 		struct tc_fq_codel_qd_stats qdisc_stats;
 		struct tc_fq_codel_cl_stats class_stats;
-	};
+	} u;
+#define qdisc_stats u.qdisc_stats
+#define class_stats u.class_stats
 };
 
 #endif
Signature · 1 line
1.7.8.6
#1 lore raw
Quoted 17 lines · On Mon, 14 May 2012 19:14:47 +0200 Sasha Levin <[email protected]> wrote:

Fix the following build error:

net/sched/sch_fq_codel.c: In function 'fq_codel_dump_stats':
net/sched/sch_fq_codel.c:464:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:464:3: warning: missing braces around initializer net/sched/sch_fq_codel.c:464:3: warning: (near initialization for 'st.<anonymous>') net/sched/sch_fq_codel.c:465:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:465:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:466:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:466:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:467:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:467:3: warning: (near initialization for 'st') make[1]: *** [net/sched/sch_fq_codel.o] Error 1

Quoted 1 line

Which Gcc version, looks like your compiler is old.

#2 lore raw
Quoted 20 lines · Stephen Hemminger
Quoted 17 lines · On Mon, 14 May 2012 19:14:47 +0200 Sasha Levin <[email protected]> wrote:

Fix the following build error:

net/sched/sch_fq_codel.c: In function 'fq_codel_dump_stats':
net/sched/sch_fq_codel.c:464:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:464:3: warning: missing braces around initializer net/sched/sch_fq_codel.c:464:3: warning: (near initialization for 'st.<anonymous>') net/sched/sch_fq_codel.c:465:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:465:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:466:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:466:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:467:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:467:3: warning: (near initialization for 'st') make[1]: *** [net/sched/sch_fq_codel.o] Error 1

Quoted 3 lines
Quoted 1 line

Which Gcc version, looks like your compiler is old.

gcc version 4.5.3 (Gentoo 4.5.3-r2 p1.1, pie-0.4.7)

This is the latest gcc provided by gentoo.

#3 lore raw
In reply to Sasha Levin
Quoted 27 lines · Sasha Levin

Fix the following build error:

net/sched/sch_fq_codel.c: In function 'fq_codel_dump_stats':
net/sched/sch_fq_codel.c:464:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:464:3: warning: missing braces around initializer net/sched/sch_fq_codel.c:464:3: warning: (near initialization for 'st.<anonymous>') net/sched/sch_fq_codel.c:465:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:465:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:466:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:466:3: warning: (near initialization for 'st') net/sched/sch_fq_codel.c:467:3: error: unknown field 'qdisc_stats' specified in initializer net/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializer net/sched/sch_fq_codel.c:467:3: warning: (near initialization for 'st') make[1]: *** [net/sched/sch_fq_codel.o] Error 1

---
 include/linux/pkt_sched.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
include/linux/pkt_sched.h +0 -0
index 32aef0a..c304eda 100644

include/linux/pkt_sched.h struct tc_fq_codel_xstats { · line 739

Quoted 9 lines
include/linux/pkt_sched.h +3 -1
@@ -732,7 +732,9 @@ struct tc_fq_codel_xstats {
 	union {
 		struct tc_fq_codel_qd_stats qdisc_stats;
 		struct tc_fq_codel_cl_stats class_stats;
-	};
+	} u;
+#define qdisc_stats u.qdisc_stats
+#define class_stats u.class_stats
 };
 

Anonymous unions are fine, we use them a lot in kernel.

Please fix the initializers instead in fq_codel_dump_stats(), because these two #define are not very nice.

maintainer
#4 lore raw

From: Eric Dumazet <[email protected]>
Date: Mon, 14 May 2012 23:08:03 +0200

Quoted 4 lines

Anonymous unions are fine, we use them a lot in kernel.

Please fix the initializers instead in fq_codel_dump_stats(), because these two #define are not very nice.

Agreed.

#5 lore raw
In reply to Eric Dumazet
Quoted 1 line · Eric Dumazet

Anonymous unions are fine, we use them a lot in kernel.

While we use them a lot, we don't try initializing them that often.

Quoted 2 lines

Please fix the initializers instead in fq_codel_dump_stats(), because these two #define are not very nice.

The only method I know of fixing that up is getting braces around them in the initializer, which is hacky and will break every time a new member is added to the struct before the anonymous union. Is there a different solution?

#6 lore raw
Quoted 5 lines · Sasha Levin
Quoted 1 line · Eric Dumazet

Anonymous unions are fine, we use them a lot in kernel.

While we use them a lot, we don't try initializing them that often.

Quoted 7 lines
Quoted 2 lines

Please fix the initializers instead in fq_codel_dump_stats(), because these two #define are not very nice.

The only method I know of fixing that up is getting braces around them in the initializer, which is hacky and will break every time a new member is added to the struct before the anonymous union. Is there a different solution?

instead of

	struct foo x = {
		.field = value;
		.sub.f2 = xxx;
		...
	};

use :

	struct foo x = {
		.field = value;
	};

	x.sub.f2 = xxx;
	...