From: Adrien Mazarguil <adrien.mazarguil-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: Stephen Hemminger
<stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] enic: disable debug traces
Date: Mon, 13 Apr 2015 12:32:40 +0200 [thread overview]
Message-ID: <20150413103240.GI32147@6wind.com> (raw)
In-Reply-To: <20150409092853.06f127c5@urahara>
On Thu, Apr 09, 2015 at 09:28:53AM -0700, Stephen Hemminger wrote:
> On Thu, 9 Apr 2015 10:32:24 +0200
> Adrien Mazarguil <adrien.mazarguil-pdR9zngts4EAvxtiuMwx3w@public.gmane.org> wrote:
>
> > >
> > > +#ifdef RTE_LIBRTE_ENIC_DEBUG
> > > #define ENICPMD_FUNC_TRACE() \
> > > RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
> > > +#else
> > > +#define ENICPMD_FUNC_TRACE() do {} while (0)
> >
> > How about defining it as (void)0 instead of an empty do/while block?
> >
> > Doing so will prevent warnings if this macro happens to be used in an
> > expression. RTE_LOG() supports it.
>
> I kind of like the Linux printk trick since it then preserves the format checking
> even if compiled out.
>
> /*
> * Dummy printk for disabled debugging statements to use whilst maintaining
> * gcc's format and side-effect checking.
> */
> static inline __printf(1, 2)
> int no_printk(const char *fmt, ...)
> {
> return 0;
> }
>
> /* pr_devel() should produce zero code unless DEBUG is defined */
> #ifdef DEBUG
> #define pr_devel(fmt, ...) \
> printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
> #else
> #define pr_devel(fmt, ...) \
> no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
> #endif
My only concern with this is that it cannot be done in a ISO C compliant
manner easily.
While "__printf()" can be defined to nothing when dealing with compilers
that do not support extensions, ", ## __VAR_ARGS__" will most likely fail
with -pedantic.
--
Adrien Mazarguil
6WIND
next prev parent reply other threads:[~2015-04-13 10:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 17:40 [PATCH] enic: disable debug traces Thomas Monjalon
[not found] ` <1428428419-25145-1-git-send-email-thomas.monjalon-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2015-04-08 3:29 ` Sujith Sankar (ssujith)
2015-04-09 8:32 ` Adrien Mazarguil
[not found] ` <20150409083223.GF32147-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2015-04-09 16:28 ` Stephen Hemminger
2015-04-13 10:32 ` Adrien Mazarguil [this message]
2015-04-13 20:12 ` Thomas Monjalon
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=20150413103240.GI32147@6wind.com \
--to=adrien.mazarguil-pdr9zngts4eavxtiumwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
--cc=stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.