]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: sched: remove redundant NULL check in change hook function
authorZhengchao Shao <shaozhengchao@huawei.com>
Mon, 29 Aug 2022 07:12:19 +0000 (15:12 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 1 Sep 2022 06:06:45 +0000 (08:06 +0200)
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>
13 files changed:
net/sched/sch_cake.c
net/sched/sch_codel.c
net/sched/sch_ets.c
net/sched/sch_fq.c
net/sched/sch_fq_codel.c
net/sched/sch_fq_pie.c
net/sched/sch_gred.c
net/sched/sch_hfsc.c
net/sched/sch_hhf.c
net/sched/sch_netem.c
net/sched/sch_pie.c
net/sched/sch_plug.c
net/sched/sch_red.c

index a43a58a73d0961c27278b8e43ed60878706396c5..36acc95d611e5c243795ab8f0d0271dd99722812 100644 (file)
@@ -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)
index 30169b3adbbb064c51b6006755d56446570f974c..d7a4874543de5d49796a353645e685d1e2e49e0a 100644 (file)
@@ -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)
index 8de4365886e84950e7a521d0649df94075471845..a3aea22ef09da5dbfa347f6e073c369aa0a95750 100644 (file)
@@ -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;
index 2fb76fc0cc31bf732e0b32a95d8e45f457acb683..48d14fb90ba02d00411e3fb51ea9fd56ffeec149 100644 (file)
@@ -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)
index 23a042adb74d8d80771a87a032d37cc0aff76aa5..f16f471daa8105d9705ffbcc166832824cdff9ac 100644 (file)
@@ -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)
index 35c35465226bdb432556cbe79424a6045d74c089..6980796d435d9d496bbf6db773dc6d8b5857c50c 100644 (file)
@@ -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;
index e7af53f607bbdf1cd2f67fbc0d22cf9fcd57fa1a..44af3b18eed901527bbc4e2a6e945ae3f54b0401 100644 (file)
@@ -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)
index 03efc40e42fc44143bc96b5acc5cf2fb7df902b5..c8bef923c79c04d12c0f6a20a5e31809ff9e7235 100644 (file)
@@ -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);
 
index 420ede8753229faae172c0829b60d81e8eaa8de8..d26cd436cbe31bd37b1b651e0760845ae7ea2616 100644 (file)
@@ -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)
index 5449ed114e40688ac575deb73d9c94bc877b7902..b70ac04110dd50612e29a422c8173053221286c6 100644 (file)
@@ -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)
index 5a457ff61acd8731a8e31ab729c7e127aa6611b5..974038ba6c7b879d0b550178e210a12a41320763 100644 (file)
@@ -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)
index cbc2ebca4548c927070dd2dbd7685cdb6a7ffe8f..ea8c4a7174bba0880851be8631f9234bdecc3ada 100644 (file)
@@ -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;
index f7ac40c0335ed64ba657fde4d08d5ec8f28c61e4..4952406f70b95073f56c56084d76649ddf2d9af6 100644 (file)
@@ -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)