netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, jhs@mojatatu.com, mlxsw@mellanox.com
Subject: [patch net-next 6/6] sched: check negative err value to safe one level of indent
Date: Thu,  9 Feb 2017 14:39:00 +0100	[thread overview]
Message-ID: <1486647540-14656-7-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1486647540-14656-1-git-send-email-jiri@resnulli.us>

From: Jiri Pirko <jiri@mellanox.com>

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>
---
 net/sched/cls_api.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 48864ad..abe1fe1 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -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;
@@ -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);
@@ -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);
-- 
2.7.4

  parent reply	other threads:[~2017-02-09 13:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-09 13:38 [patch net-next 0/6] sched: cls_api: small cleanup Jiri Pirko
2017-02-09 13:38 ` [patch net-next 1/6] sched: rename tcf_destroy to tcf_destroy_proto Jiri Pirko
2017-02-09 18:20   ` Jamal Hadi Salim
2017-02-09 13:38 ` [patch net-next 2/6] sched: move tcf_proto_destroy and tcf_destroy_chain helpers into cls_api Jiri Pirko
2017-02-09 18:21   ` Jamal Hadi Salim
2017-02-14 17:25   ` Sabrina Dubroca
2017-02-14 17:26     ` Jiri Pirko
2017-02-09 13:38 ` [patch net-next 3/6] sched: push TC filter protocol creation into a separate function Jiri Pirko
2017-02-09 18:23   ` Jamal Hadi Salim
2017-02-09 13:38 ` [patch net-next 4/6] sched: move err set right before goto errout in tc_ctl_tfilter Jiri Pirko
2017-02-09 18:25   ` Jamal Hadi Salim
2017-02-09 13:38 ` [patch net-next 5/6] sched: add missing curly braces in else branch " Jiri Pirko
2017-02-09 18:27   ` Jamal Hadi Salim
2017-02-09 21:45     ` Jiri Pirko
2017-02-09 13:39 ` Jiri Pirko [this message]
2017-02-09 18:32   ` [patch net-next 6/6] sched: check negative err value to safe one level of indent Jamal Hadi Salim
2017-02-10 16:38 ` [patch net-next 0/6] sched: cls_api: small cleanup David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1486647540-14656-7-git-send-email-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).