Skip to content

Commit

Permalink
net: sched: remove redundant NULL check in change hook function
Browse files Browse the repository at this point in the history
Currently, the change function can be called by two ways. The one way is
that qdisc_change() will call it. Before calling change function,
qdisc_change() ensures tca[TCA_OPTIONS] is not empty. The other way is
that .init() will call it. The opt parameter is also checked before
calling change function in .init(). Therefore, it's no need to check the
input parameter opt in change function.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Acked-by: Toke Høiland-Jørgensen <toke@toke.dk>
Link: https://lore.kernel.org/r/20220829071219.208646-1-shaozhengchao@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Zhengchao Shao authored and Paolo Abeni committed Sep 1, 2022
1 parent 0e4d354 commit a102c89
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 39 deletions.
3 changes: 0 additions & 3 deletions net/sched/sch_cake.c
Original file line number Diff line number Diff line change
Expand Up @@ -2569,9 +2569,6 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt,
struct nlattr *tb[TCA_CAKE_MAX + 1];
int err;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_CAKE_MAX, opt, cake_policy,
extack);
if (err < 0)
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_codel.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,6 @@ static int codel_change(struct Qdisc *sch, struct nlattr *opt,
unsigned int qlen, dropped = 0;
int err;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_CODEL_MAX, opt,
codel_policy, NULL);
if (err < 0)
Expand Down
5 changes: 0 additions & 5 deletions net/sched/sch_ets.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,6 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,
unsigned int i;
int err;

if (!opt) {
NL_SET_ERR_MSG(extack, "ETS options are required for this operation");
return -EINVAL;
}

err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
if (err < 0)
return err;
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_fq.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,6 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt,
unsigned drop_len = 0;
u32 fq_log;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_FQ_MAX, opt, fq_policy,
NULL);
if (err < 0)
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_fq_codel.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
u32 quantum = 0;
int err;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_FQ_CODEL_MAX, opt,
fq_codel_policy, NULL);
if (err < 0)
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_fq_pie.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,
unsigned int num_dropped = 0;
int err;

if (!opt)
return -EINVAL;

err = nla_parse_nested(tb, TCA_FQ_PIE_MAX, opt, fq_pie_policy, extack);
if (err < 0)
return err;
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_gred.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,6 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
u32 max_P;
struct gred_sched_data *prealloc;

if (opt == NULL)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_GRED_MAX, opt, gred_policy,
extack);
if (err < 0)
Expand Down
2 changes: 1 addition & 1 deletion net/sched/sch_hfsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt,
struct hfsc_sched *q = qdisc_priv(sch);
struct tc_hfsc_qopt *qopt;

if (opt == NULL || nla_len(opt) < sizeof(*qopt))
if (nla_len(opt) < sizeof(*qopt))
return -EINVAL;
qopt = nla_data(opt);

Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_hhf.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,9 +516,6 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt,
u32 new_quantum = q->quantum;
u32 new_hhf_non_hh_weight = q->hhf_non_hh_weight;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_HHF_MAX, opt, hhf_policy,
NULL);
if (err < 0)
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_netem.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,6 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,
int old_loss_model = CLG_RANDOM;
int ret;

if (opt == NULL)
return -EINVAL;

qopt = nla_data(opt);
ret = parse_attr(tb, TCA_NETEM_MAX, opt, netem_policy, sizeof(*qopt));
if (ret < 0)
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_pie.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ static int pie_change(struct Qdisc *sch, struct nlattr *opt,
unsigned int qlen, dropped = 0;
int err;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_PIE_MAX, opt, pie_policy,
NULL);
if (err < 0)
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,6 @@ static int plug_change(struct Qdisc *sch, struct nlattr *opt,
struct plug_sched_data *q = qdisc_priv(sch);
struct tc_plug_qopt *msg;

if (opt == NULL)
return -EINVAL;

msg = nla_data(opt);
if (nla_len(opt) < sizeof(*msg))
return -EINVAL;
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_red.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,6 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt,
struct nlattr *tb[TCA_RED_MAX + 1];
int err;

if (!opt)
return -EINVAL;

err = nla_parse_nested_deprecated(tb, TCA_RED_MAX, opt, red_policy,
extack);
if (err < 0)
Expand Down

0 comments on commit a102c89

Please sign in to comment.