Thread (9 messages) 9 messages, 2 authors, 2015-09-29
STALE3893d
Revisions (2)
  1. v3 current
  2. v4 [diff vs current]

[PATCH v3 1/2] [net] af_unix: Convert the unix_sk macro to an inline function for type safety

From: Aaron Conole <hidden>
Date: 2015-09-22 00:27:13
Subsystem: networking [general], networking [unix sockets], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Kuniyuki Iwashima, Linus Torvalds

As suggested by Eric Dumazet in
http://marc.info/?l=linux-netdev&m=144276759421433&w=2

This change replaces the #define with a static inline function to
enjoy complaints by the compiler when misusing the API.

Signed-off-by: Aaron Conole <redacted>
---
 include/net/af_unix.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 4a167b3..cb1b9bb 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -63,7 +63,11 @@ struct unix_sock {
 #define UNIX_GC_MAYBE_CYCLE	1
 	struct socket_wq	peer_wq;
 };
-#define unix_sk(__sk) ((struct unix_sock *)__sk)
+
+static inline struct unix_sock *unix_sk(struct sock *sk)
+{
+	return (struct unix_sock *)sk;
+}
 
 #define peer_wait peer_wq.wait
 
-- 
1.9.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help