Re: New sparse warning in net/mac80211/debugfs_sta.c

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Patrick McHardy <kaber@...>
Cc: David Miller <davem@...>, <johannes@...>, <harvey.harrison@...>, <netdev@...>
Date: Tuesday, April 8, 2008 - 5:02 pm

On Tue, 2008-04-08 at 22:18 +0200, Patrick McHardy wrote:

[]

I also think this should be cleaned up before 2.6.25 is released.

I think that the changes to pr_debug, dev_dbg, and dev_vdbg
to use an "if (0) printk" macro rather than an empty inline
I posted a few times without any reply or comment should work
for most all cases.

These changes should allow gcc to eliminate unused functions
called as arguments to those debugging logging functions
while maintaining the printf argument validation.

I'll check out codiff as I haven't used it.
Is this the latest codiff tool?
http://git.kernel.org/?p=linux/kernel/git/acme/pahole.git;a=summary

cheers, Joe

Here is the patch again:

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/include/linux/device.h b/include/linux/device.h
index 2258d89..12bb248 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -608,21 +608,21 @@ extern const char *dev_driver_string(struct device *dev);
 #define dev_dbg(dev, format, arg...)		\
 	dev_printk(KERN_DEBUG , dev , format , ## arg)
 #else
-static inline int __attribute__ ((format (printf, 2, 3)))
-dev_dbg(struct device *dev, const char *fmt, ...)
-{
-	return 0;
-}
+#define dev_dbg(dev, format, arg...)				\
+do {								\
+	if (0)							\
+		dev_printk(KERN_DEBUG , dev , format , ## arg);	\
+} while (0)
 #endif
 
 #ifdef VERBOSE_DEBUG
 #define dev_vdbg	dev_dbg
 #else
-static inline int __attribute__ ((format (printf, 2, 3)))
-dev_vdbg(struct device *dev, const char *fmt, ...)
-{
-	return 0;
-}
+#define dev_vdbg(dev, format, arg...)				\
+do {								\
+	if (0)							\
+		dev_printk(KERN_DEBUG , dev , format , ## arg);	\
+} while (0)
 #endif
 
 /* Create alias, so I can be autoloaded. */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2df44e7..80be070 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -293,10 +293,11 @@ extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
 #define pr_debug(fmt, arg...) \
 	printk(KERN_DEBUG fmt, ##arg)
 #else
-static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char * fmt, ...)
-{
-	return 0;
-}
+#define pr_debug(fmt, arg...)			\
+do {						\
+	if (0)					\
+		printk(KERN_DEBUG fmt, ##arg);	\
+} while (0)
 #endif
 
 /*


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: New sparse warning in net/mac80211/debugfs_sta.c, Harvey Harrison, (Thu Feb 21, 6:01 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Thu Feb 21, 6:05 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Thu Feb 21, 1:45 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Thu Feb 21, 1:17 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Thu Feb 21, 6:17 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Thu Feb 21, 1:54 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Thu Feb 21, 2:00 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Thu Feb 21, 2:15 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Sun Feb 24, 12:02 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Mon Feb 25, 7:47 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Mon Feb 25, 3:58 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Tue Apr 8, 4:18 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Tue Apr 8, 5:02 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Tue Apr 8, 5:19 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Tue Apr 8, 6:09 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Patrick McHardy, (Tue Apr 8, 6:32 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Tue Apr 8, 6:30 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Tue Apr 8, 6:41 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Tue Apr 8, 5:16 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 5:53 am)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Mon Feb 25, 3:52 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 3:56 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Mon Feb 25, 4:12 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 4:05 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, David Miller, (Mon Feb 25, 4:14 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 1:23 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Joe Perches, (Mon Feb 25, 12:53 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Johannes Berg, (Mon Feb 25, 1:29 pm)
Re: New sparse warning in net/mac80211/debugfs_sta.c, Harvey Harrison, (Thu Feb 21, 6:14 am)