Skip to content

Commit a102c89

Browse files
zhengchaoshaoPaolo Abeni
authored andcommitted
net: sched: remove redundant NULL check in change hook function
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>
1 parent 0e4d354 commit a102c89

File tree

13 files changed

+1
-39
lines changed

13 files changed

+1
-39
lines changed

net/sched/sch_cake.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,9 +2569,6 @@ static int cake_change(struct Qdisc *sch, struct nlattr *opt,
25692569
struct nlattr *tb[TCA_CAKE_MAX + 1];
25702570
int err;
25712571

2572-
if (!opt)
2573-
return -EINVAL;
2574-
25752572
err = nla_parse_nested_deprecated(tb, TCA_CAKE_MAX, opt, cake_policy,
25762573
extack);
25772574
if (err < 0)

net/sched/sch_codel.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ static int codel_change(struct Qdisc *sch, struct nlattr *opt,
138138
unsigned int qlen, dropped = 0;
139139
int err;
140140

141-
if (!opt)
142-
return -EINVAL;
143-
144141
err = nla_parse_nested_deprecated(tb, TCA_CODEL_MAX, opt,
145142
codel_policy, NULL);
146143
if (err < 0)

net/sched/sch_ets.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,6 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,
594594
unsigned int i;
595595
int err;
596596

597-
if (!opt) {
598-
NL_SET_ERR_MSG(extack, "ETS options are required for this operation");
599-
return -EINVAL;
600-
}
601-
602597
err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
603598
if (err < 0)
604599
return err;

net/sched/sch_fq.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,6 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt,
808808
unsigned drop_len = 0;
809809
u32 fq_log;
810810

811-
if (!opt)
812-
return -EINVAL;
813-
814811
err = nla_parse_nested_deprecated(tb, TCA_FQ_MAX, opt, fq_policy,
815812
NULL);
816813
if (err < 0)

net/sched/sch_fq_codel.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,6 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
372372
u32 quantum = 0;
373373
int err;
374374

375-
if (!opt)
376-
return -EINVAL;
377-
378375
err = nla_parse_nested_deprecated(tb, TCA_FQ_CODEL_MAX, opt,
379376
fq_codel_policy, NULL);
380377
if (err < 0)

net/sched/sch_fq_pie.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,6 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,
283283
unsigned int num_dropped = 0;
284284
int err;
285285

286-
if (!opt)
287-
return -EINVAL;
288-
289286
err = nla_parse_nested(tb, TCA_FQ_PIE_MAX, opt, fq_pie_policy, extack);
290287
if (err < 0)
291288
return err;

net/sched/sch_gred.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,6 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
648648
u32 max_P;
649649
struct gred_sched_data *prealloc;
650650

651-
if (opt == NULL)
652-
return -EINVAL;
653-
654651
err = nla_parse_nested_deprecated(tb, TCA_GRED_MAX, opt, gred_policy,
655652
extack);
656653
if (err < 0)

net/sched/sch_hfsc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt,
14301430
struct hfsc_sched *q = qdisc_priv(sch);
14311431
struct tc_hfsc_qopt *qopt;
14321432

1433-
if (opt == NULL || nla_len(opt) < sizeof(*qopt))
1433+
if (nla_len(opt) < sizeof(*qopt))
14341434
return -EINVAL;
14351435
qopt = nla_data(opt);
14361436

net/sched/sch_hhf.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,6 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt,
516516
u32 new_quantum = q->quantum;
517517
u32 new_hhf_non_hh_weight = q->hhf_non_hh_weight;
518518

519-
if (!opt)
520-
return -EINVAL;
521-
522519
err = nla_parse_nested_deprecated(tb, TCA_HHF_MAX, opt, hhf_policy,
523520
NULL);
524521
if (err < 0)

net/sched/sch_netem.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,6 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,
961961
int old_loss_model = CLG_RANDOM;
962962
int ret;
963963

964-
if (opt == NULL)
965-
return -EINVAL;
966-
967964
qopt = nla_data(opt);
968965
ret = parse_attr(tb, TCA_NETEM_MAX, opt, netem_policy, sizeof(*qopt));
969966
if (ret < 0)

0 commit comments

Comments
 (0)