Subject: [PATCH] socket: SOCK_DEBUG type checking

From: Stephen Hemminger <[email-masked]>
Date: Fri, 21 Mar 2008 07:51:32 -0700

Use the inline trick (same as pr_debug) to get checking
of debug statements even if no code is generated.

Signed-off-by: Stephen Hemminger <[email-masked]>

--- a/include/net/sock.h	2008-03-20 20:25:04.000000000 -0700
+++ b/include/net/sock.h	2008-03-20 20:28:48.000000000 -0700
@@ -70,7 +70,11 @@
 #define SOCK_DEBUG(sk, msg...) do { if ((sk) && sock_flag((sk), SOCK_DBG)) \
 					printk(KERN_DEBUG msg); } while (0)
 #else
-#define SOCK_DEBUG(sk, msg...) do { } while (0)
+/* Validate arguments and do nothing */
+static void inline int __attribute__ ((format (printf, 2, 3)))
+SOCK_DEBUG(struct sock *sk, const char *msg, ...)
+{
+}
 #endif
 
 /* This is the per-socket lock.  The spinlock provides a synchronization