@@ -57,7 +57,7 @@ struct codel_skb_cb {
static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb)
{
- qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct codel_skb_cb));
return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data;
}
@@ -109,7 +109,7 @@ static inline void pie_vars_init(struct pie_vars *vars)
static inline struct pie_skb_cb *get_pie_cb(const struct sk_buff *skb)
{
- qdisc_cb_private_validate(skb, sizeof(struct pie_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct pie_skb_cb));
return (struct pie_skb_cb *)qdisc_skb_cb(skb)->data;
}
@@ -459,12 +459,11 @@ static inline bool lockdep_tcf_proto_is_locked(struct tcf_proto *tp)
#define tcf_proto_dereference(p, tp) \
rcu_dereference_protected(p, lockdep_tcf_proto_is_locked(tp))
-static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
+static inline void qdisc_cb_private_validate(int sz)
{
- struct qdisc_skb_cb *qcb;
-
- BUILD_BUG_ON(sizeof(skb->cb) < offsetof(struct qdisc_skb_cb, data) + sz);
- BUILD_BUG_ON(sizeof(qcb->data) < sz);
+ BUILD_BUG_ON(sizeof_field(struct sk_buff, cb) <
+ offsetof(struct qdisc_skb_cb, data) + sz);
+ BUILD_BUG_ON(sizeof_field(struct qdisc_skb_cb, data) < sz);
}
static inline int qdisc_qlen_cpu(const struct Qdisc *q)
@@ -281,7 +281,7 @@ static u64 us_to_ns(u64 us)
static struct cobalt_skb_cb *get_cobalt_cb(const struct sk_buff *skb)
{
- qdisc_cb_private_validate(skb, sizeof(struct cobalt_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct cobalt_skb_cb));
return (struct cobalt_skb_cb *)qdisc_skb_cb(skb)->data;
}
@@ -137,7 +137,7 @@ struct choke_skb_cb {
static inline struct choke_skb_cb *choke_skb_cb(const struct sk_buff *skb)
{
- qdisc_cb_private_validate(skb, sizeof(struct choke_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct choke_skb_cb));
return (struct choke_skb_cb *)qdisc_skb_cb(skb)->data;
}
@@ -56,7 +56,7 @@ struct fq_skb_cb {
static inline struct fq_skb_cb *fq_skb_cb(struct sk_buff *skb)
{
- qdisc_cb_private_validate(skb, sizeof(struct fq_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct fq_skb_cb));
return (struct fq_skb_cb *)qdisc_skb_cb(skb)->data;
}
@@ -161,7 +161,7 @@ struct netem_skb_cb {
static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb)
{
/* we assume we can use skb next/prev/tstamp as storage for rb_node */
- qdisc_cb_private_validate(skb, sizeof(struct netem_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct netem_skb_cb));
return (struct netem_skb_cb *)qdisc_skb_cb(skb)->data;
}
@@ -91,7 +91,7 @@ struct sfb_skb_cb {
static inline struct sfb_skb_cb *sfb_skb_cb(const struct sk_buff *skb)
{
- qdisc_cb_private_validate(skb, sizeof(struct sfb_skb_cb));
+ qdisc_cb_private_validate(sizeof(struct sfb_skb_cb));
return (struct sfb_skb_cb *)qdisc_skb_cb(skb)->data;
}
Compiling with -Wunused triggers the following warning: ./include/net/sch_generic.h: In function ‘qdisc_cb_private_validate’: ./include/net/sch_generic.h:464:23: warning: unused variable ‘qcb’ [-Wunused-variable] 464 | struct qdisc_skb_cb *qcb; | ^~~ as the qcb variable is only used to compute the sizeof one of its members. Get rid of the warning by using the provided sizeof_member() macro and avoid having a variable at all. At the same time use sizeof_member() also for computing the sizeof skb->cb, thus avoiding ‘qdisc_cb_private_validate’ to have an skb argument at all. Cc: Toke Høiland-Jørgensen <toke@toke.dk> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Jiri Pirko <jiri@resnulli.us> Cc: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Antonio Quartulli <a@unstable.cc> --- Affected code has been compile-tested on x86_64 include/net/codel_qdisc.h | 2 +- include/net/pie.h | 2 +- include/net/sch_generic.h | 9 ++++----- net/sched/sch_cake.c | 2 +- net/sched/sch_choke.c | 2 +- net/sched/sch_fq.c | 2 +- net/sched/sch_netem.c | 2 +- net/sched/sch_sfb.c | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-)