Skip to content

Commit

Permalink
sched: check negative err value to safe one level of indent
Browse files Browse the repository at this point in the history
As it is more common, check err for !0. That allows to safe one level of
indentation and makes the code easier to read. Also, make 'next' variable
global in function as it is used twice.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Feb 10, 2017
1 parent 7215032 commit 40c81b2
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
struct Qdisc *q;
struct tcf_proto __rcu **back;
struct tcf_proto __rcu **chain;
struct tcf_proto *next;
struct tcf_proto *tp;
const struct Qdisc_class_ops *cops;
unsigned long cl;
Expand Down Expand Up @@ -355,10 +356,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)

if (fh == 0) {
if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) {
struct tcf_proto *next = rtnl_dereference(tp->next);

next = rtnl_dereference(tp->next);
RCU_INIT_POINTER(*back, next);

tfilter_notify(net, skb, n, tp, fh,
RTM_DELTFILTER, false);
tcf_proto_destroy(tp, true);
Expand All @@ -383,16 +382,13 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
break;
case RTM_DELTFILTER:
err = tp->ops->delete(tp, fh);
if (err == 0) {
struct tcf_proto *next = rtnl_dereference(tp->next);

tfilter_notify(net, skb, n, tp,
t->tcm_handle,
RTM_DELTFILTER, false);
if (tcf_proto_destroy(tp, false))
RCU_INIT_POINTER(*back, next);
}
goto errout;
if (err)
goto errout;
next = rtnl_dereference(tp->next);
tfilter_notify(net, skb, n, tp, t->tcm_handle,
RTM_DELTFILTER, false);
if (tcf_proto_destroy(tp, false))
RCU_INIT_POINTER(*back, next);
case RTM_GETTFILTER:
err = tfilter_notify(net, skb, n, tp, fh,
RTM_NEWTFILTER, true);
Expand Down

0 comments on commit 40c81b2

Please sign in to comment.