From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH] enic: disable debug traces Date: Mon, 13 Apr 2015 12:32:40 +0200 Message-ID: <20150413103240.GI32147@6wind.com> References: <1428428419-25145-1-git-send-email-thomas.monjalon@6wind.com> <20150409083223.GF32147@6wind.com> <20150409092853.06f127c5@urahara> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev-VfR2kkLFssw@public.gmane.org To: Stephen Hemminger Return-path: Content-Disposition: inline In-Reply-To: <20150409092853.06f127c5@urahara> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" On Thu, Apr 09, 2015 at 09:28:53AM -0700, Stephen Hemminger wrote: > On Thu, 9 Apr 2015 10:32:24 +0200 > Adrien Mazarguil 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