[AF_PACKET]: Fix minor code duplication
authorUrs Thuermann <urs@isnogud.escape.de>
Tue, 13 Nov 2007 05:05:20 +0000 (21:05 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Nov 2007 05:05:20 +0000 (21:05 -0800)
Simplify some code by eliminating duplicate if-else clauses in
packet_do_bind().

Signed-off-by: Urs Thuermann <urs@isnogud.escape.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c

index eb6be5030c70ea7e0bb8b28af520e34fa4f4805a..8a7807dbba012bdc03b0b49a8a1f35a02e9ee288 100644 (file)
@@ -881,20 +881,14 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
        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: