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 <declan.doherty at intel.com> >> --- >> 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 <stdio.h> >> #include <sys/queue.h> >> >> +#include <rte_log.h> >> + >> +__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); >> +} >> + <snip> >> -- >> 2.4.3 >> >