From mboxrd@z Thu Jan 1 00:00:00 1970 From: Declan Doherty Subject: Re: [PATCH v5 02/10] ethdev: make error checking macros public Date: Tue, 10 Nov 2015 17:00:51 +0000 Message-ID: <564222C3.6000405@intel.com> References: <1446572746-26207-1-git-send-email-declan.doherty@intel.com> <1447101259-18972-1-git-send-email-declan.doherty@intel.com> <1447101259-18972-3-git-send-email-declan.doherty@intel.com> <20151110155053.GU4013@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit To: dev@dpdk.org, Bruce Richardson Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id E4B7E3787 for ; Tue, 10 Nov 2015 17:55:58 +0100 (CET) In-Reply-To: <20151110155053.GU4013@6wind.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 10/11/15 15:50, Adrien Mazarguil wrote: > On Mon, Nov 09, 2015 at 08:34:11PM +0000, Declan Doherty wrote: >> Move the function pointer and port id checking macros to rte_ethdev and >> rte_dev header files, so that they can be used in the static inline >> functions there. Also replace the RTE_LOG call within >> RTE_PMD_DEBUG_TRACE so this macro can be built with the -pedantic flag >> >> Signed-off-by: Declan Doherty >> --- >> lib/librte_eal/common/include/rte_dev.h | 52 +++++++++++++++++++++++++++++++ >> lib/librte_ether/rte_ethdev.c | 54 --------------------------------- >> lib/librte_ether/rte_ethdev.h | 26 ++++++++++++++++ >> 3 files changed, 78 insertions(+), 54 deletions(-) >> >> diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h >> index f601d21..fd09b3d 100644 >> --- a/lib/librte_eal/common/include/rte_dev.h >> +++ b/lib/librte_eal/common/include/rte_dev.h >> @@ -46,8 +46,60 @@ >> extern "C" { >> #endif >> >> +#include >> #include >> >> +#include >> + >> +__attribute__((format(printf, 2, 0))) >> +static inline void >> +rte_pmd_debug_trace(const char *func_name, const char *fmt, ...) >> +{ >> + va_list ap; >> + >> + va_start(ap, fmt); > > I suggest adding an empty line here since we're mixing code and > declarations. > sure no problem. >> + char buffer[vsnprintf(NULL, 0, fmt, ap)]; > > I forgot an extra byte for trailing '\0' in my original comment, the above > line should read: > > char buffer[vsnprintf(NULL, 0, fmt, ap) + 1]; > > Otherwise the last character will be missing. Did you test that function? > I didn't notice the truncation in the log message, I was just missing and "!" in the log message and didn't miss it. I'll push a new version with this fix. >> + >> + 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); >> +} >> + >> -- >> 2.4.3 >> >