Skip to contentSkip to conversation

socket: SOCK_DEBUG type checking

PATCH In review Stephen Hemminger 2 participants 3 messages Mar 21, 2008 – Mar 22, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 socket: SOCK_DEBUG type checking

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

include/net/sock.h +5 -1
@@ -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
maintainer
#1 lore raw

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

Quoted 4 lines

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

Applied, and I'll push to net-2.6.26 after some build testing.

Although the use of SOCK_DEBUG is so esoteric and sparse, I can't see how any of it can be useful for any kind of debugging.

I'd say we should just remove this thing.

#2 lore raw
Quoted 8 lines · On Fri, 21 Mar 2008 15:56:00 -0700 (PDT) David Miller <[email protected]>…

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

Quoted 4 lines

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

Quoted 8 lines

Applied, and I'll push to net-2.6.26 after some build testing.

Although the use of SOCK_DEBUG is so esoteric and sparse, I can't see how any of it can be useful for any kind of debugging.

I'd say we should just remove this thing.

Agreed, that was the other alternative, just saw it while looking at filter stuff.