public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches•com>
To: "Jason A. Donenfeld" <Jason@zx2c4•com>
Cc: Andrew Morton <akpm@linux-foundation•org>,
	"David S. Miller" <davem@davemloft•net>,
	netdev@vger•kernel.org, linux-kernel@vger•kernel.org
Subject: Re: [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG
Date: Tue, 04 Aug 2015 08:51:05 -0700	[thread overview]
Message-ID: <1438703465.10829.20.camel@perches.com> (raw)
In-Reply-To: <1438700836-6715-1-git-send-email-Jason@zx2c4.com>

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

  parent reply	other threads:[~2015-08-04 15:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-04  3:26 [PATCH] net_dbg_ratelimited: turn into no-op when !DEBUG Jason A. Donenfeld
2015-08-04  3:57 ` Joe Perches
2015-08-04  4:02   ` Joe Perches
2015-08-04  4:59     ` David Miller
2015-08-04 15:07       ` Jason A. Donenfeld
2015-08-04 15:08         ` Jason A. Donenfeld
2015-08-04 15:51         ` Joe Perches [this message]
2015-08-04 16:26           ` [PATCH v3] " Jason A. Donenfeld
2015-08-07  6:51             ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1438703465.10829.20.camel@perches.com \
    --to=joe@perches$(echo .)com \
    --cc=Jason@zx2c4$(echo .)com \
    --cc=akpm@linux-foundation$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox