From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by dpdk.org (Postfix) with ESMTP id 45043C37E for ; Mon, 13 Apr 2015 12:32:42 +0200 (CEST) Received: by widdi4 with SMTP id di4so46195727wid.0 for ; Mon, 13 Apr 2015 03:32:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to; bh=CVnA7Nevxa6I4PHzGGSgLaL1uoDc+E8zBJv+Cu1kGhA=; b=Bbt7Zm/OIxYgrMW+UJhQGghr1ty1KojuYsluwCdQdnkM52veIMWymzLoVscaRSXwpy C3tS+wGo0eZHsoQHHR990uU1sSGI+QjkR+eQy6xRfRTKmBVZwsnVH46bddcNPbtxujy2 i6u9ZIWOtqr3waYdyMvcmy7bobtU/AR7xELwPWdDK489ecKfvssOjogTCW8zwXc4GoZG 47PSmMS4ZgNzlyxM/l5rWcAz2YkpKDMHJ/exHOS3hWKGzSw8s9Lc/keEmi4KX0ztHFf+ aaRb6/dWHDLSrFiDOM+7E0wLkwGg3PWlPibEph4jhFuxGOpx/TO3EUi9N4yad0m5Pddu k/Kw== X-Gm-Message-State: ALoCoQkGcbASopTr49Qgq0Xv50Bmt//S5tEfEbntncc9O/L4lfriCm9V61SZWMay21LBxLopK8Xx X-Received: by 10.194.78.231 with SMTP id e7mr25961859wjx.33.1428921162049; Mon, 13 Apr 2015 03:32:42 -0700 (PDT) Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id ax10sm10863874wjc.26.2015.04.13.03.32.40 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 13 Apr 2015 03:32:41 -0700 (PDT) Date: Mon, 13 Apr 2015 12:32:40 +0200 From: Adrien Mazarguil To: Stephen Hemminger Message-ID: <20150413103240.GI32147@6wind.com> Mail-Followup-To: Stephen Hemminger , Thomas Monjalon , dev@dpdk.org 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 Content-Disposition: inline In-Reply-To: <20150409092853.06f127c5@urahara> Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] enic: disable debug traces X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Apr 2015 10:32:42 -0000 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