netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] clean up tcp_sk(), 2.6.0
@ 2003-12-30 16:32 Ingo Molnar
  2003-12-30 16:50 ` YOSHIFUJI Hideaki / 吉藤英明
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ingo Molnar @ 2003-12-30 16:32 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel, netdev


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
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-12-31 10:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-30 16:32 [patch] clean up tcp_sk(), 2.6.0 Ingo Molnar
2003-12-30 16:50 ` YOSHIFUJI Hideaki / 吉藤英明
2003-12-30 16:57 ` Arnaldo Carvalho de Melo
2003-12-30 22:46 ` David S. Miller
2003-12-31 10:12   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).