[dpdk-dev] [PATCH] enic: disable debug traces

Stephen Hemminger stephen at networkplumber.org
Thu Apr 9 18:28:53 CEST 2015


On Thu, 9 Apr 2015 10:32:24 +0200
Adrien Mazarguil <adrien.mazarguil at 6wind.com> 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


More information about the dev mailing list