net: codel: fix build errors
Subsystems (2)
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
@@ -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
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 initializernet/sched/sch_fq_codel.c:464:3: warning: missing braces around initializernet/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 initializernet/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializernet/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 initializernet/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializernet/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 initializernet/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializernet/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
Signed-off-by Sasha Levin <[email protected]>
Which Gcc version, looks like your compiler is old.
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 initializernet/sched/sch_fq_codel.c:464:3: warning: missing braces around initializernet/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 initializernet/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializernet/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 initializernet/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializernet/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 initializernet/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializernet/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
Signed-off-by Sasha Levin <[email protected]>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.
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 initializernet/sched/sch_fq_codel.c:464:3: warning: missing braces around initializernet/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 initializernet/sched/sch_fq_codel.c:465:3: warning: excess elements in struct initializernet/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 initializernet/sched/sch_fq_codel.c:466:3: warning: excess elements in struct initializernet/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 initializernet/sched/sch_fq_codel.c:467:3: warning: excess elements in struct initializernet/sched/sch_fq_codel.c:467:3: warning: (near initialization for 'st') make[1]: *** [net/sched/sch_fq_codel.o] Error 1Signed-off-by Sasha Levin <[email protected]>--- include/linux/pkt_sched.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)include/linux/pkt_sched.h +0
-0
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.
David Miller
maintainerFrom: 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.
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?
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;
...