From: Adrien Mazarguil Date: Wed, 19 Dec 2012 16:05:54 +0000 (+0100) Subject: lib: fix non-C99 macros definitions in exported headers X-Git-Tag: spdx-start~11279 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=77d7a99fbe379418bd5df4ea01bff5a1ff494a5a;p=dpdk.git lib: fix non-C99 macros definitions in exported headers The original definitions prevent external programs/libraries from compiling without warnings when using these headers and -std=gnu99 (relaxed C99 mode). Signed-off-by: Adrien Mazarguil Acked-by: Ivan Boule Acked-by: Damien Millescamps --- diff --git a/lib/librte_cmdline/cmdline_cirbuf.h b/lib/librte_cmdline/cmdline_cirbuf.h index eb83ea8630..7e25439b2d 100644 --- a/lib/librte_cmdline/cmdline_cirbuf.h +++ b/lib/librte_cmdline/cmdline_cirbuf.h @@ -78,9 +78,10 @@ struct cirbuf { }; #ifdef RTE_LIBRTE_CMDLINE_DEBUG -#define dprintf(fmt, ...) printf("line %3.3d - " fmt, __LINE__, ##__VA_ARGS__) +#define dprintf_(fmt, ...) printf("line %3.3d - " fmt "%.0s", __LINE__, __VA_ARGS__) +#define dprintf(...) dprintf_(__VA_ARGS__, "dummy") #else -#define dprintf(args...) do {} while(0) +#define dprintf(...) (void)0 #endif diff --git a/lib/librte_eal/common/include/rte_debug.h b/lib/librte_eal/common/include/rte_debug.h index 9045a70cc9..e997514ae0 100644 --- a/lib/librte_eal/common/include/rte_debug.h +++ b/lib/librte_eal/common/include/rte_debug.h @@ -76,7 +76,8 @@ void rte_dump_registers(void); * @param args * The variable list of arguments. */ -#define rte_panic(format, args...) __rte_panic(__func__, format, ## args) +#define rte_panic_(func, format, ...) __rte_panic(func, format "%.0s", __VA_ARGS__) +#define rte_panic(...) rte_panic_(__func__, __VA_ARGS__, "dummy") /* * Provide notification of a critical non-recoverable error and stop. diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h index fc6c9b8a00..3f697c3db2 100644 --- a/lib/librte_eal/common/include/rte_log.h +++ b/lib/librte_eal/common/include/rte_log.h @@ -275,14 +275,13 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap); * - 0: Success. * - Negative on error. */ -#define RTE_LOG(l, t, fmt, args...) ({ \ - if ((RTE_LOG_##l <= RTE_LOG_LEVEL) && \ - (RTE_LOG_##l <= rte_logs.level) && \ - (RTE_LOGTYPE_##t & rte_logs.type)) { \ - rte_log(RTE_LOG_##l, RTE_LOGTYPE_##t, \ - #t ": " fmt, ## args); \ - } \ -}) +#define RTE_LOG(l, t, ...) \ + (((RTE_LOG_ ## l <= RTE_LOG_LEVEL) && \ + (RTE_LOG_ ## l <= rte_logs.level) && \ + (RTE_LOGTYPE_ ## t & rte_logs.type)) ? \ + rte_log(RTE_LOG_ ## l, \ + RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ + 0) #ifdef __cplusplus }