Skip to content

Commit

Permalink
[AF_PACKET]: Fix minor code duplication
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Urs Thuermann authored and David S. Miller committed Nov 13, 2007
1 parent 57ce45d commit be85d4a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit be85d4a

Please sign in to comment.