netdev
[Top] [All Lists]

[patch] clean up tcp_sk(), 2.6.0

To: "David S. Miller" <davem@xxxxxxxxxx>
Subject: [patch] clean up tcp_sk(), 2.6.0
From: Ingo Molnar <mingo@xxxxxxx>
Date: Tue, 30 Dec 2003 17:32:30 +0100
Cc: linux-kernel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx
Sender: netdev-bounce@xxxxxxxxxxx
User-agent: Mutt/1.4.1i
i recently wasted a few hours on a bug where i used "tcp_sk(sock)"
instead of "tcp_sk(sock->sk)" - the former, while being blatantly
incorrect, compiles just fine on 2.6.0. The patch below is equivalent to
the define but is also type-safe. Compiles cleanly & boots fine on
2.6.0.

        Ingo

--- linux/include/linux/tcp.h.orig
+++ linux/include/linux/tcp.h
@@ -386,7 +386,10 @@ struct tcp_sock {
        struct tcp_opt    tcp;
 };
 
-#define tcp_sk(__sk) (&((struct tcp_sock *)__sk)->tcp)
+static inline struct tcp_opt * tcp_sk(const struct sock *__sk)
+{
+       return &((struct tcp_sock *)__sk)->tcp;
+}
 
 #endif
 

<Prev in Thread] Current Thread [Next in Thread>