netdev
[Top] [All Lists]

[PATCH] (2/13) ddp - invert logic for clarity

To: Jay Schulist <jschlst@xxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxx>
Subject: [PATCH] (2/13) ddp - invert logic for clarity
From: Stephen Hemminger <shemminger@xxxxxxxx>
Date: Fri, 29 Aug 2003 13:54:27 -0700
Cc: netdev@xxxxxxxxxxx
Organization: Open Source Development Lab
Sender: netdev-bounce@xxxxxxxxxxx
It is a lot clearer to invert the logic used in the destroy_socket
so that it ends up as a positive expression, rather than a double negative.

The SOCK_DEAD is redundant and can be eliminated because it is always
set in the atalk_release() the only caller.

diff -Nru a/net/appletalk/ddp.c b/net/appletalk/ddp.c
--- a/net/appletalk/ddp.c       Fri Aug 29 11:02:41 2003
+++ b/net/appletalk/ddp.c       Fri Aug 29 11:02:41 2003
@@ -183,13 +183,12 @@
 {
        struct sock *sk = (struct sock *)data;
 
-       if (!atomic_read(&sk->sk_wmem_alloc) &&
-           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
-               sock_put(sk);
-       else {
+       if (atomic_read(&sk->sk_wmem_alloc) ||
+           atomic_read(&sk->sk_rmem_alloc)) {
                sk->sk_timer.expires = jiffies + SOCK_DESTROY_TIME;
                add_timer(&sk->sk_timer);
-       }
+       } else
+               sock_put(sk);
 }
 
 static inline void atalk_destroy_socket(struct sock *sk)
@@ -197,16 +196,15 @@
        atalk_remove_socket(sk);
        skb_queue_purge(&sk->sk_receive_queue);
 
-       if (!atomic_read(&sk->sk_wmem_alloc) &&
-           !atomic_read(&sk->sk_rmem_alloc) && sock_flag(sk, SOCK_DEAD))
-               sock_put(sk);
-       else {
+       if (atomic_read(&sk->sk_wmem_alloc) ||
+           atomic_read(&sk->sk_rmem_alloc)) {
                init_timer(&sk->sk_timer);
                sk->sk_timer.expires    = jiffies + SOCK_DESTROY_TIME;
                sk->sk_timer.function   = atalk_destroy_timer;
                sk->sk_timer.data       = (unsigned long)sk;
                add_timer(&sk->sk_timer);
-       }
+       } else
+               sock_put(sk);
 }
 
 /**************************************************************************\

<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] (2/13) ddp - invert logic for clarity, Stephen Hemminger <=