[PATCH] [AF_PACKET] Fix minor code duplication

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Urs Thuermann
Date: Friday, November 9, 2007 - 12:06 am

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:
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] [AF_PACKET] Fix minor code duplication, Urs Thuermann, (Fri Nov 9, 12:06 am)
Re: [PATCH] [AF_PACKET] Fix minor code duplication, David Miller, (Mon Nov 12, 10:05 pm)