Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1200113

Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG
Date 2015-08-04 18:00 +0200
Message-ID <pTMNd-6DQ-15@gated-at.bofh.it> (permalink)
References <pTCuu-7r-7@gated-at.bofh.it> <pTM0O-5Ik-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 2015-08-04 at 17:07 +0200, Jason A. Donenfeld wrote:
> The pr_debug family of functions turns into a no-op when -DDEBUG is not
> specified, opting instead to call "no_printk", which gets compiled to a
> no-op (but retains gcc's nice warnings about printf-style arguments).
[]
> diff --git a/include/linux/net.h b/include/linux/net.h
[]
> @@ -239,8 +239,14 @@ do {								\
>  	net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
>  #define net_info_ratelimited(fmt, ...)				\
>  	net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
> +#if defined(DEBUG)
>  #define net_dbg_ratelimited(fmt, ...)				\
>  	net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
> +#else
> +#define net_dbg_ratelimited(fmt, ...)				\
> +	if (0)							\
> +		no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
> +#endif

This should be:

#define net_dbg_ratelimited(fmt, ...)				\
do {								\
	if (0)							\
		no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); \
} while (0)

to be safe in if/else uses


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-08-04 05:30 +0200
  Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG Joe Perches <joe@perches.com> - 2015-08-04 06:00 +0200
    Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG Joe Perches <joe@perches.com> - 2015-08-04 06:10 +0200
      Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG David Miller <davem@davemloft.net> - 2015-08-04 07:00 +0200
        Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-08-04 17:10 +0200
        [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-08-04 17:10 +0200
          Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG Joe Perches <joe@perches.com> - 2015-08-04 18:00 +0200
            [PATCH v3] net_dbg_ratelimited: turn into no-op when !DEBUG "Jason A. Donenfeld" <Jason@zx2c4.com> - 2015-08-04 18:30 +0200
              Re: [PATCH v3] net_dbg_ratelimited: turn into no-op when !DEBUG David Miller <davem@davemloft.net> - 2015-08-07 09:00 +0200

csiph-web