aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_htb.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2009-09-04 02:41:17 -0400
committerDavid S. Miller <davem@davemloft.net>2009-09-06 05:07:02 -0400
commit5b9a9ccfad8553dbf7a9b17ba78bad70215ed0e2 (patch)
tree1454e8121fef6635a615f6766b3fdbff678ae63d /net/sched/sch_htb.c
parentde6d5cdf881353f83006d5f3e28ac4fffd42145e (diff)
net_sched: remove some unnecessary checks in classful schedulers
The class argument to the ->graft(), ->leaf(), ->dump(), ->dump_stats() all originate from either ->get() or ->walk() and are always valid. Remove unnecessary checks. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_htb.c')
-rw-r--r--net/sched/sch_htb.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index ec4d46399d59..85acab9dc6fd 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1117,30 +1117,29 @@ static int htb_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
1117{ 1117{
1118 struct htb_class *cl = (struct htb_class *)arg; 1118 struct htb_class *cl = (struct htb_class *)arg;
1119 1119
1120 if (cl && !cl->level) { 1120 if (cl->level)
1121 if (new == NULL && 1121 return -EINVAL;
1122 (new = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue, 1122 if (new == NULL &&
1123 &pfifo_qdisc_ops, 1123 (new = qdisc_create_dflt(qdisc_dev(sch), sch->dev_queue,
1124 cl->common.classid)) 1124 &pfifo_qdisc_ops,
1125 == NULL) 1125 cl->common.classid)) == NULL)
1126 return -ENOBUFS; 1126 return -ENOBUFS;
1127 sch_tree_lock(sch); 1127
1128 *old = cl->un.leaf.q; 1128 sch_tree_lock(sch);
1129 cl->un.leaf.q = new; 1129 *old = cl->un.leaf.q;
1130 if (*old != NULL) { 1130 cl->un.leaf.q = new;
1131 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen); 1131 if (*old != NULL) {
1132 qdisc_reset(*old); 1132 qdisc_tree_decrease_qlen(*old, (*old)->q.qlen);
1133 } 1133 qdisc_reset(*old);
1134 sch_tree_unlock(sch);
1135 return 0;
1136 } 1134 }
1137 return -ENOENT; 1135 sch_tree_unlock(sch);
1136 return 0;
1138} 1137}
1139 1138
1140static struct Qdisc *htb_leaf(struct Qdisc *sch, unsigned long arg) 1139static struct Qdisc *htb_leaf(struct Qdisc *sch, unsigned long arg)
1141{ 1140{
1142 struct htb_class *cl = (struct htb_class *)arg; 1141 struct htb_class *cl = (struct htb_class *)arg;
1143 return (cl && !cl->level) ? cl->un.leaf.q : NULL; 1142 return !cl->level ? cl->un.leaf.q : NULL;
1144} 1143}
1145 1144
1146static void htb_qlen_notify(struct Qdisc *sch, unsigned long arg) 1145static void htb_qlen_notify(struct Qdisc *sch, unsigned long arg)