From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id ECF558E7A for ; Wed, 4 Nov 2015 16:25:41 +0100 (CET) Received: by wmff134 with SMTP id f134so44468042wmf.0 for ; Wed, 04 Nov 2015 07:25:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind_com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to; bh=LVlOjWZ5ZIwuQqTWCB5uuig5QZGtEcFYHPpxzzV4L6g=; b=xtKCOu3s/ELTuDkM58y9lauVAzVOPAC/wE/Z0BJK/3hSSjAZgauVzr/3vEi7KvynRT BzcVu9pjoRwqGOYdh9GMXebaBAmQKQ090qpb4DKva0d/yrHixRcLqplyX6k719CDzBzH ZMxkaGGfBVR1jHB2CXBt3gnVu2CrvwwrdoO6vAt/cw4PlHpYVCygOoycS+p1jJLOMSLg U8KQPFeMm2XidwK6qLNN6xiLxxw+8sOkgu0Y1MxrejvRcxMhBufTIeC1I80p/gVO5WrH biLzUZIbKaYpeqadldXjPLf/gPrI3BHNBjYkWMA6NJk325rrnE49HfjGFFsMdlLXs+Cp hZBA== 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=LVlOjWZ5ZIwuQqTWCB5uuig5QZGtEcFYHPpxzzV4L6g=; b=BRpujt8e3W22r4b+PY87t79DteT7ZIgrPrPPQ7S9TSYVyClpYxHEBgLwp6wZ6vbG01 nXDkkijC/j8KpLmWJn4mvgOp8ksAVjdYo/mGJdi32LKxUu6gHcR4wfVodhFm3Nuqf8KY /D2itLuEw3+/2gHr6FohwtndUwxQJ7/Dqg24eqMQA58xa+N0G8BskLPgc/7qPItj4dJh obHO0OELj7UJ/ixdGOTR/bkMUnPbwLIJlpB+lV+q3aBQsQvv45L2gAfHfrpvb9xP5+0c wGQrV8VI29+Wij76dCRobt5y5xxrbPWHldXYvXU5W7WJRCz/5jCCEK53HLEoLiexk7dH w3ww== X-Gm-Message-State: ALoCoQmJJMJdtJQA6CuOo52bN5AI1GcUJPVGPlQ42lR+VabsKN9pWgWE8NZ0FNHj5PkSn+uZqL25 X-Received: by 10.28.211.143 with SMTP id k137mr4233065wmg.49.1446650741752; Wed, 04 Nov 2015 07:25:41 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id l1sm29168418wmb.1.2015.11.04.07.25.40 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Nov 2015 07:25:41 -0800 (PST) Date: Wed, 4 Nov 2015 16:25:21 +0100 From: Adrien Mazarguil To: Bruce Richardson Message-ID: <20151104152521.GS3518@6wind.com> Mail-Followup-To: Bruce Richardson , Thomas Monjalon , dev@dpdk.org References: <1441811374-28984-1-git-send-email-bruce.richardson@intel.com> <1446552059-5446-1-git-send-email-bruce.richardson@intel.com> <1446552059-5446-3-git-send-email-bruce.richardson@intel.com> <4698587.GS9blBozDC@xps13> <20151104102418.GN3518@6wind.com> <20151104141050.GA19636@bricha3-MOBL3> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151104141050.GA19636@bricha3-MOBL3> Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros to header 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: Wed, 04 Nov 2015 15:25:42 -0000 On Wed, Nov 04, 2015 at 02:10:50PM +0000, Bruce Richardson wrote: > On Wed, Nov 04, 2015 at 11:24:18AM +0100, Adrien Mazarguil wrote: > > On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote: > > > 2015-11-03 12:00, Bruce Richardson: > > > > Move the function ptr and port id checking macros to the header file, so > > > > that they can be used in the static inline functions there. In doxygen > > > > comments, mark them as for internal use only. > > > [...] > > > > +/** > > > > + * @internal > > > > + * Macro to print a message if in debugging mode > > > > + */ > > > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \ > > > > + RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args) > > > > +#else > > > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) > > > > +#endif > > > > > > It does not compile because Mellanox drivers are pedantic: > > > > > > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0: > > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level: > > > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros] > > > #define RTE_PMD_DEBUG_TRACE(fmt, args...) \ > > > > I suggest something like the following definitions as a pedantic-proof and > > standard compliant method (one drawback being that it cannot be done with a > > single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also > > automatically appends a line feed: > > > > #ifdef RTE_LIBRTE_ETHDEV_DEBUG > > > > #define STRIP(a, b) a > > #define OPAREN ( > > #define CPAREN ) > > #define COMMA , > > > > #define RTE_PMD_DEBUG_TRACE(...) \ > > RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN) > > > > #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \ > > RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__) > > > > #define RTE_PMD_DEBUG_TRACE__(...) \ > > RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__) > > > > #else /* RTE_LIBRTE_ETHDEV_DEBUG */ > > > > #define RTE_PMD_DEBUG_TRACE(...) > > > > #endif /* RTE_LIBRTE_ETHDEV_DEBUG */ > > > > STRIP() and other helper macros are used to manage the dangling comma issue > > when __VA_ARGS__ is empty as in the first call below: > > > > RTE_PMD_DEBUG_TRACE("foo\n"); > > RTE_PMD_DEBUG_TRACE("foo %u\n", 42); > > > > -- > > Adrien Mazarguil > > 6WIND > > Is this really the best way around this? It looks like a lot more complicated > than the original solution. Do we really need to support the -pedantic flag > in our header files? I know you didn't ask me directly but I think we should, at least for exposed/installed headers. What we do internally does not matter, but we cannot prevent user applications from adding -pedantic if they want to. The above solution is one I suggest, perhaps it can be done in a different manner if you think it's too complicated, although it's difficult using macros only. -- Adrien Mazarguil 6WIND