From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH v3 2/4] ethdev: move error checking macros to header Date: Tue, 10 Nov 2015 17:08:06 +0100 Message-ID: <20151110160806.GV4013@6wind.com> References: <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> <20151104103957.4cabd090@xeon-e3> <20151105150918.GV3518@6wind.com> <20151106171007.GB19512@bricha3-MOBL3> <20151106172227.GC19512@bricha3-MOBL3> <20151109133905.GL4013@6wind.com> <59AF69C657FD0841A61C55336867B5B03598018B@IRSMSX103.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "dev@dpdk.org" To: "Richardson, Bruce" Return-path: Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id CA11B3772 for ; Tue, 10 Nov 2015 17:08:27 +0100 (CET) Received: by wmww144 with SMTP id w144so7113233wmw.0 for ; Tue, 10 Nov 2015 08:08:27 -0800 (PST) Content-Disposition: inline In-Reply-To: <59AF69C657FD0841A61C55336867B5B03598018B@IRSMSX103.ger.corp.intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Mon, Nov 09, 2015 at 02:02:28PM +0000, Richardson, Bruce wrote: [...] > > From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com] [...] > > Untested but I guess modifying that function accordingly would look like: > > > > static inline void > > rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) > > { > > va_list ap; > > va_start(ap, fmt); > > > > static __thread char buffer[vsnprintf(NULL, 0, fmt, ap)]; > > > > va_end(ap); > > va_start(ap, fmt); > > vsnprintf(buffer, sizeof(buffer), fmt, ap); > > va_end(ap); > > rte_log(RTE_LOG_ERR, RTE_LOGTYPE_PMD, "%s: %s", func_name, > > buffer); > > } > > > > Looks a much better option. > > From this, though, I assume then that we are only looking to support the -pedantic flag in conjuction with c99 mode or above. Supporting -pedantic with the pre-gcc-5 versions won't allow that to work though, as variably sized arrays only came in with c99, and were gnu extensions before that. Right, -pedantic must follow a given standard such as -std=gnu99 otherwise it's meaningless. However pre-GCC 5 is fine for most if not all features we use, see: https://gcc.gnu.org/c99status.html Mixed code and declarations are supported since GCC 3.0, __VA_ARGS__ in macros since GCC 2.95 and variable length arrays since GCC 0.9, so as long as we use a version that implements -std=gnu99 (or -std=c99 to be really pedantic), it's fine. Besides DPDK already uses C99 extensively, even a few C11 features (such as embedded anonymous struct definitions) currently supported in C99 mode as compiler extensions. I think we can safely ignore compilers that don't support common C99 features. -- Adrien Mazarguil 6WIND