Netdev List
 help / color / mirror / Atom feed
From: Urs Thuermann <urs.thuermann@gmx.de>
To: netdev@vger.kernel.org
Subject: [PATCH] [AF_PACKET] Fix minor code duplication
Date: 09 Nov 2007 08:06:38 +0100	[thread overview]
Message-ID: <ygfpryjaoe9.fsf@janus.isnogud.escape.de> (raw)

Simplify some code by eliminating duplicate if-else clauses in
packet_do_bind().


Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>


--- net-2.6/net/packet/af_packet.c.orig	2007-11-05 13:07:28.000000000 +0100
+++ net-2.6/net/packet/af_packet.c	2007-11-08 12:14:25.000000000 +0100
@@ -886,20 +886,14 @@ static int packet_do_bind(struct sock *s
 	if (protocol == 0)
 		goto out_unlock;
 
-	if (dev) {
-		if (dev->flags&IFF_UP) {
-			dev_add_pack(&po->prot_hook);
-			sock_hold(sk);
-			po->running = 1;
-		} else {
-			sk->sk_err = ENETDOWN;
-			if (!sock_flag(sk, SOCK_DEAD))
-				sk->sk_error_report(sk);
-		}
-	} else {
+	if (!dev || (dev->flags & IFF_UP)) {
 		dev_add_pack(&po->prot_hook);
 		sock_hold(sk);
 		po->running = 1;
+	} else {
+		sk->sk_err = ENETDOWN;
+		if (!sock_flag(sk, SOCK_DEAD))
+			sk->sk_error_report(sk);
 	}
 
 out_unlock:

             reply	other threads:[~2007-11-09  7:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-09  7:06 Urs Thuermann [this message]
2007-11-13  5:05 ` [PATCH] [AF_PACKET] Fix minor code duplication 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=ygfpryjaoe9.fsf@janus.isnogud.escape.de \
    --to=urs.thuermann@gmx.de \
    --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