Skip to content

Commit

Permalink
drivers: use portable variadic macros
Browse files Browse the repository at this point in the history
Many places are using a GCC extension related to variadic macros,
where a name prepends the ellipsis. This results in a warning like
the one below when compiling the code with MSVC:

app\test-pmd\testpmd.h(1314): error C2608:
    invalid token '...' in macro parameter list

Variadic macros became a standard part of the C language with C99.
GCC, Clang and MSVC handle them properly.

The fix is to remove the prefix name (args... becomes ...) and use
__VA_ARGS__.

Signed-off-by: Andre Muezerie <[email protected]>
Acked-by: Andrew Rybchenko <[email protected]>
  • Loading branch information
Andre Muezerie authored and david-marchand committed Dec 23, 2024
1 parent f7c9651 commit fd51012
Show file tree
Hide file tree
Showing 62 changed files with 431 additions and 429 deletions.
12 changes: 6 additions & 6 deletions drivers/bus/cdx/cdx_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ extern int cdx_logtype_bus;
#define CDX_BUS_DEBUG(...) \
RTE_LOG_LINE_PREFIX(DEBUG, CDX_BUS, "%s(): ", __func__, __VA_ARGS__)

#define CDX_BUS_INFO(fmt, args...) \
CDX_BUS_LOG(INFO, fmt, ## args)
#define CDX_BUS_ERR(fmt, args...) \
CDX_BUS_LOG(ERR, fmt, ## args)
#define CDX_BUS_WARN(fmt, args...) \
CDX_BUS_LOG(WARNING, fmt, ## args)
#define CDX_BUS_INFO(fmt, ...) \
CDX_BUS_LOG(INFO, fmt, ## __VA_ARGS__)
#define CDX_BUS_ERR(fmt, ...) \
CDX_BUS_LOG(ERR, fmt, ## __VA_ARGS__)
#define CDX_BUS_WARN(fmt, ...) \
CDX_BUS_LOG(WARNING, fmt, ## __VA_ARGS__)

#endif /* CDX_LOGS_H */
4 changes: 2 additions & 2 deletions drivers/bus/dpaa/include/fman.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,10 @@ extern int fman_ccsr_map_fd;
#define fman_if_for_each_bpool(bp, __if) \
list_for_each_entry(bp, &(__if)->bpool_list, node)

#define FMAN_ERR(rc, fmt, args...) \
#define FMAN_ERR(rc, fmt, ...) \
do { \
_errno = (rc); \
RTE_LOG_LINE(ERR, DPAA_BUS, fmt "(%d)", ##args, errno); \
RTE_LOG_LINE(ERR, DPAA_BUS, fmt "(%d)", ##__VA_ARGS__, errno); \
} while (0)

#define FMAN_IP_REV_1 0xC30C4
Expand Down
18 changes: 9 additions & 9 deletions drivers/bus/dpaa/rte_dpaa_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ extern int dpaa_logtype_bus;
RTE_LOG_LINE(level, DPAA_BUS, __VA_ARGS__)

#ifdef RTE_LIBRTE_DPAA_DEBUG_BUS
#define DPAA_BUS_HWWARN(cond, fmt, args...) \
#define DPAA_BUS_HWWARN(cond, fmt, ...) \
do {\
if (cond) \
DPAA_BUS_LOG(DEBUG, "WARN: " fmt, ##args); \
DPAA_BUS_LOG(DEBUG, "WARN: " fmt, ##__VA_ARGS__); \
} while (0)
#else
#define DPAA_BUS_HWWARN(cond, fmt, args...) do { } while (0)
#define DPAA_BUS_HWWARN(cond, fmt, ...) do { } while (0)
#endif

#define DPAA_BUS_DEBUG(...) \
RTE_LOG_LINE_PREFIX(DEBUG, DPAA_BUS, "%s(): ", __func__, __VA_ARGS__)

#define BUS_INIT_FUNC_TRACE() DPAA_BUS_DEBUG(" >>")

#define DPAA_BUS_INFO(fmt, args...) \
DPAA_BUS_LOG(INFO, fmt, ## args)
#define DPAA_BUS_ERR(fmt, args...) \
DPAA_BUS_LOG(ERR, fmt, ## args)
#define DPAA_BUS_WARN(fmt, args...) \
DPAA_BUS_LOG(WARNING, fmt, ## args)
#define DPAA_BUS_INFO(fmt, ...) \
DPAA_BUS_LOG(INFO, fmt, ## __VA_ARGS__)
#define DPAA_BUS_ERR(fmt, ...) \
DPAA_BUS_LOG(ERR, fmt, ## __VA_ARGS__)
#define DPAA_BUS_WARN(fmt, ...) \
DPAA_BUS_LOG(WARNING, fmt, ## __VA_ARGS__)

#endif /* _DPAA_LOGS_H_ */
12 changes: 6 additions & 6 deletions drivers/bus/fslmc/fslmc_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ extern int dpaa2_logtype_bus;
#define DPAA2_BUS_DEBUG(...) \
RTE_LOG_LINE_PREFIX(DEBUG, DPAA2_BUS, "%s(): ", __func__, __VA_ARGS__)

#define DPAA2_BUS_INFO(fmt, args...) \
DPAA2_BUS_LOG(INFO, fmt, ## args)
#define DPAA2_BUS_ERR(fmt, args...) \
DPAA2_BUS_LOG(ERR, fmt, ## args)
#define DPAA2_BUS_WARN(fmt, args...) \
DPAA2_BUS_LOG(WARNING, fmt, ## args)
#define DPAA2_BUS_INFO(fmt, ...) \
DPAA2_BUS_LOG(INFO, fmt, ## __VA_ARGS__)
#define DPAA2_BUS_ERR(fmt, ...) \
DPAA2_BUS_LOG(ERR, fmt, ## __VA_ARGS__)
#define DPAA2_BUS_WARN(fmt, ...) \
DPAA2_BUS_LOG(WARNING, fmt, ## __VA_ARGS__)

#endif /* _FSLMC_LOGS_H_ */
16 changes: 8 additions & 8 deletions drivers/bus/fslmc/qbman/include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
typedef uint64_t dma_addr_t;

/* Debugging */
#define prflush(fmt, args...) \
#define prflush(fmt, ...) \
do { \
printf(fmt, ##args); \
printf(fmt, ##__VA_ARGS__); \
fflush(stdout); \
} while (0)
#define pr_crit(fmt, args...) prflush("CRIT:" fmt, ##args)
#define pr_err(fmt, args...) prflush("ERR:" fmt, ##args)
#define pr_warn(fmt, args...) prflush("WARN:" fmt, ##args)
#define pr_info(fmt, args...) prflush(fmt, ##args)
#define pr_crit(fmt, ...) prflush("CRIT:" fmt, ##__VA_ARGS__)
#define pr_err(fmt, ...) prflush("ERR:" fmt, ##__VA_ARGS__)
#define pr_warn(fmt, ...) prflush("WARN:" fmt, ##__VA_ARGS__)
#define pr_info(fmt, ...) prflush(fmt, ##__VA_ARGS__)

#ifdef RTE_LIBRTE_DPAA2_DEBUG_BUS

Expand All @@ -54,7 +54,7 @@ typedef uint64_t dma_addr_t;
#ifdef pr_debug
#undef pr_debug
#endif
#define pr_debug(fmt, args...) printf(fmt, ##args)
#define pr_debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define QBMAN_BUG_ON(c) \
do { \
static int warned_##__LINE__; \
Expand All @@ -65,7 +65,7 @@ do { \
} while (0)
#else
#define QBMAN_BUG_ON(c) {}
#define pr_debug(fmt, args...) {}
#define pr_debug(fmt, ...) {}
#endif

/* Other miscellaneous interfaces our APIs depend on; */
Expand Down
16 changes: 8 additions & 8 deletions drivers/bus/ifpga/ifpga_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ extern int ifpga_bus_logtype;

#define IFPGA_BUS_FUNC_TRACE() IFPGA_BUS_LOG(DEBUG, ">>")

#define IFPGA_BUS_DEBUG(fmt, args...) \
IFPGA_BUS_LOG(DEBUG, fmt, ## args)
#define IFPGA_BUS_INFO(fmt, args...) \
IFPGA_BUS_LOG(INFO, fmt, ## args)
#define IFPGA_BUS_ERR(fmt, args...) \
IFPGA_BUS_LOG(ERR, fmt, ## args)
#define IFPGA_BUS_WARN(fmt, args...) \
IFPGA_BUS_LOG(WARNING, fmt, ## args)
#define IFPGA_BUS_DEBUG(fmt, ...) \
IFPGA_BUS_LOG(DEBUG, fmt, ## __VA_ARGS__)
#define IFPGA_BUS_INFO(fmt, ...) \
IFPGA_BUS_LOG(INFO, fmt, ## __VA_ARGS__)
#define IFPGA_BUS_ERR(fmt, ...) \
IFPGA_BUS_LOG(ERR, fmt, ## __VA_ARGS__)
#define IFPGA_BUS_WARN(fmt, ...) \
IFPGA_BUS_LOG(WARNING, fmt, ## __VA_ARGS__)

#endif /* _IFPGA_BUS_LOGS_H_ */
8 changes: 4 additions & 4 deletions drivers/bus/uacce/uacce.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ extern int uacce_bus_logtype;
#define RTE_LOGTYPE_UACCE_BUS uacce_bus_logtype
#define UACCE_BUS_LOG(level, ...) \
RTE_LOG_LINE(level, UACCE_BUS, __VA_ARGS__)
#define UACCE_BUS_ERR(fmt, args...) UACCE_BUS_LOG(ERR, fmt, ##args)
#define UACCE_BUS_WARN(fmt, args...) UACCE_BUS_LOG(WARNING, fmt, ##args)
#define UACCE_BUS_INFO(fmt, args...) UACCE_BUS_LOG(INFO, fmt, ##args)
#define UACCE_BUS_DEBUG(fmt, args...) UACCE_BUS_LOG(DEBUG, fmt, ##args)
#define UACCE_BUS_ERR(fmt, ...) UACCE_BUS_LOG(ERR, fmt, ##__VA_ARGS__)
#define UACCE_BUS_WARN(fmt, ...) UACCE_BUS_LOG(WARNING, fmt, ##__VA_ARGS__)
#define UACCE_BUS_INFO(fmt, ...) UACCE_BUS_LOG(INFO, fmt, ##__VA_ARGS__)
#define UACCE_BUS_DEBUG(fmt, ...) UACCE_BUS_LOG(DEBUG, fmt, ##__VA_ARGS__)


static struct rte_devargs *
Expand Down
16 changes: 8 additions & 8 deletions drivers/common/dpaax/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

/* Debugging */
#define prflush(fmt, args...) \
#define prflush(fmt, ...) \
do { \
printf(fmt, ##args); \
printf(fmt, ##__VA_ARGS__); \
fflush(stdout); \
} while (0)
#ifndef pr_crit
#define pr_crit(fmt, args...) prflush("CRIT:" fmt, ##args)
#define pr_crit(fmt, ...) prflush("CRIT:" fmt, ##__VA_ARGS__)
#endif
#ifndef pr_err
#define pr_err(fmt, args...) prflush("ERR:" fmt, ##args)
#define pr_err(fmt, ...) prflush("ERR:" fmt, ##__VA_ARGS__)
#endif
#ifndef pr_warn
#define pr_warn(fmt, args...) prflush("WARN:" fmt, ##args)
#define pr_warn(fmt, ...) prflush("WARN:" fmt, ##__VA_ARGS__)
#endif
#ifndef pr_info
#define pr_info(fmt, args...) prflush(fmt, ##args)
#define pr_info(fmt, ...) prflush(fmt, ##__VA_ARGS__)
#endif
#ifndef pr_debug
#ifdef RTE_LIBRTE_DPAA_DEBUG_BUS
#define pr_debug(fmt, args...) printf(fmt, ##args)
#define pr_debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define pr_debug(fmt, args...) {}
#define pr_debug(fmt, ...) {}
#endif
#endif

Expand Down
18 changes: 9 additions & 9 deletions drivers/common/dpaax/dpaax_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ extern int dpaax_logger;
#define RTE_LOGTYPE_DPAAX_LOGGER dpaax_logger

#ifdef RTE_LIBRTE_DPAAX_DEBUG
#define DPAAX_HWWARN(cond, fmt, args...) \
#define DPAAX_HWWARN(cond, fmt, ...) \
do {\
if (cond) \
DPAAX_LOG(DEBUG, "WARN: " fmt, ##args); \
DPAAX_LOG(DEBUG, "WARN: " fmt, ##__VA_ARGS__); \
} while (0)
#else
#define DPAAX_HWWARN(cond, fmt, args...) do { } while (0)
#define DPAAX_HWWARN(cond, fmt, ...) do { } while (0)
#endif

#define DPAAX_LOG(level, ...) \
Expand All @@ -27,11 +27,11 @@ extern int dpaax_logger;
#define DPAAX_DEBUG(...) \
RTE_LOG_LINE_PREFIX(DEBUG, DPAAX_LOGGER, "%s(): ", __func__, __VA_ARGS__)

#define DPAAX_INFO(fmt, args...) \
DPAAX_LOG(INFO, fmt, ## args)
#define DPAAX_ERR(fmt, args...) \
DPAAX_LOG(ERR, fmt, ## args)
#define DPAAX_WARN(fmt, args...) \
DPAAX_LOG(WARNING, fmt, ## args)
#define DPAAX_INFO(fmt, ...) \
DPAAX_LOG(INFO, fmt, ## __VA_ARGS__)
#define DPAAX_ERR(fmt, ...) \
DPAAX_LOG(ERR, fmt, ## __VA_ARGS__)
#define DPAAX_WARN(fmt, ...) \
DPAAX_LOG(WARNING, fmt, ## __VA_ARGS__)

#endif /* _DPAAX_LOGS_H_ */
8 changes: 5 additions & 3 deletions drivers/common/idpf/base/idpf_osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef uint64_t s64;
typedef struct idpf_lock idpf_lock;

#define __iomem
#define hw_dbg(hw, S, A...) do {} while (0)
#define hw_dbg(hw, S, ...) do {} while (0)
#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
#define lower_32_bits(n) ((u32)(n))
#define low_16_bits(x) ((x) & 0xFFFF)
Expand Down Expand Up @@ -122,8 +122,10 @@ typedef struct idpf_lock idpf_lock;
##__VA_ARGS__); \
} while (0)

#define idpf_info(hw, fmt, args...) idpf_debug(hw, IDPF_DBG_ALL, fmt, ##args)
#define idpf_warn(hw, fmt, args...) idpf_debug(hw, IDPF_DBG_ALL, fmt, ##args)
#define idpf_info(hw, fmt, ...) \
idpf_debug(hw, IDPF_DBG_ALL, fmt, ##__VA_ARGS__)
#define idpf_warn(hw, fmt, ...) \
idpf_debug(hw, IDPF_DBG_ALL, fmt, ##__VA_ARGS__)
#define idpf_debug_array(hw, type, rowsize, groupsize, buf, len) \
do { \
struct idpf_hw *hw_l = hw; \
Expand Down
8 changes: 4 additions & 4 deletions drivers/compress/octeontx/otx_zip.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ extern int octtx_zip_logtype_driver;
#define ZIP_PMD_LOG(level, ...) \
RTE_LOG_LINE_PREFIX(level, OCTTX_ZIP_DRIVER, "%s(): ", __func__, __VA_ARGS__)

#define ZIP_PMD_INFO(fmt, args...) \
ZIP_PMD_LOG(INFO, fmt, ## args)
#define ZIP_PMD_ERR(fmt, args...) \
ZIP_PMD_LOG(ERR, fmt, ## args)
#define ZIP_PMD_INFO(fmt, ...) \
ZIP_PMD_LOG(INFO, fmt, ## __VA_ARGS__)
#define ZIP_PMD_ERR(fmt, ...) \
ZIP_PMD_LOG(ERR, fmt, ## __VA_ARGS__)

/* resources required to process stream */
enum NUM_BUFS_PER_STREAM {
Expand Down
12 changes: 6 additions & 6 deletions drivers/compress/zlib/zlib_pmd_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ extern int zlib_logtype_driver;
#define ZLIB_PMD_LOG(level, ...) \
RTE_LOG_LINE_PREFIX(level, ZLIB_DRIVER, "%s(): ", __func__, __VA_ARGS__)

#define ZLIB_PMD_INFO(fmt, args...) \
ZLIB_PMD_LOG(INFO, fmt, ## args)
#define ZLIB_PMD_ERR(fmt, args...) \
ZLIB_PMD_LOG(ERR, fmt, ## args)
#define ZLIB_PMD_WARN(fmt, args...) \
ZLIB_PMD_LOG(WARNING, fmt, ## args)
#define ZLIB_PMD_INFO(fmt, ...) \
ZLIB_PMD_LOG(INFO, fmt, ## __VA_ARGS__)
#define ZLIB_PMD_ERR(fmt, ...) \
ZLIB_PMD_LOG(ERR, fmt, ## __VA_ARGS__)
#define ZLIB_PMD_WARN(fmt, ...) \
ZLIB_PMD_LOG(WARNING, fmt, ## __VA_ARGS__)

struct zlib_private {
struct rte_mempool *mp;
Expand Down
28 changes: 14 additions & 14 deletions drivers/crypto/caam_jr/caam_jr_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ extern int caam_jr_logtype;

#define PMD_INIT_FUNC_TRACE() CAAM_JR_DEBUG(" >>")

#define CAAM_JR_INFO(fmt, args...) \
CAAM_JR_LOG(INFO, fmt, ## args)
#define CAAM_JR_ERR(fmt, args...) \
CAAM_JR_LOG(ERR, fmt, ## args)
#define CAAM_JR_WARN(fmt, args...) \
CAAM_JR_LOG(WARNING, fmt, ## args)
#define CAAM_JR_INFO(fmt, ...) \
CAAM_JR_LOG(INFO, fmt, ## __VA_ARGS__)
#define CAAM_JR_ERR(fmt, ...) \
CAAM_JR_LOG(ERR, fmt, ## __VA_ARGS__)
#define CAAM_JR_WARN(fmt, ...) \
CAAM_JR_LOG(WARNING, fmt, ## __VA_ARGS__)

/* DP Logs, toggled out at compile time if level lower than current level */
#define CAAM_JR_DP_LOG(level, ...) \
RTE_LOG_DP_LINE(level, CAAM_JR, __VA_ARGS__)

#define CAAM_JR_DP_DEBUG(fmt, args...) \
CAAM_JR_DP_LOG(DEBUG, fmt, ## args)
#define CAAM_JR_DP_INFO(fmt, args...) \
CAAM_JR_DP_LOG(INFO, fmt, ## args)
#define CAAM_JR_DP_WARN(fmt, args...) \
CAAM_JR_DP_LOG(WARNING, fmt, ## args)
#define CAAM_JR_DP_ERR(fmt, args...) \
CAAM_JR_DP_LOG(ERR, fmt, ## args)
#define CAAM_JR_DP_DEBUG(fmt, ...) \
CAAM_JR_DP_LOG(DEBUG, fmt, ## __VA_ARGS__)
#define CAAM_JR_DP_INFO(fmt, ...) \
CAAM_JR_DP_LOG(INFO, fmt, ## __VA_ARGS__)
#define CAAM_JR_DP_WARN(fmt, ...) \
CAAM_JR_DP_LOG(WARNING, fmt, ## __VA_ARGS__)
#define CAAM_JR_DP_ERR(fmt, ...) \
CAAM_JR_DP_LOG(ERR, fmt, ## __VA_ARGS__)

#endif /* _CAAM_JR_LOG_H_ */
28 changes: 14 additions & 14 deletions drivers/crypto/dpaa2_sec/dpaa2_sec_logs.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ extern int dpaa2_logtype_sec;

#define PMD_INIT_FUNC_TRACE() DPAA2_SEC_DEBUG(">>")

#define DPAA2_SEC_INFO(fmt, args...) \
DPAA2_SEC_LOG(INFO, fmt, ## args)
#define DPAA2_SEC_ERR(fmt, args...) \
DPAA2_SEC_LOG(ERR, fmt, ## args)
#define DPAA2_SEC_WARN(fmt, args...) \
DPAA2_SEC_LOG(WARNING, fmt, ## args)
#define DPAA2_SEC_INFO(fmt, ...) \
DPAA2_SEC_LOG(INFO, fmt, ## __VA_ARGS__)
#define DPAA2_SEC_ERR(fmt, ...) \
DPAA2_SEC_LOG(ERR, fmt, ## __VA_ARGS__)
#define DPAA2_SEC_WARN(fmt, ...) \
DPAA2_SEC_LOG(WARNING, fmt, ## __VA_ARGS__)

/* DP Logs, toggled out at compile time if level lower than current level */
#define DPAA2_SEC_DP_LOG(level, ...) \
RTE_LOG_DP_LINE(level, DPAA2_SEC, __VA_ARGS__)

#define DPAA2_SEC_DP_DEBUG(fmt, args...) \
DPAA2_SEC_DP_LOG(DEBUG, fmt, ## args)
#define DPAA2_SEC_DP_INFO(fmt, args...) \
DPAA2_SEC_DP_LOG(INFO, fmt, ## args)
#define DPAA2_SEC_DP_WARN(fmt, args...) \
DPAA2_SEC_DP_LOG(WARNING, fmt, ## args)
#define DPAA2_SEC_DP_ERR(fmt, args...) \
DPAA2_SEC_DP_LOG(ERR, fmt, ## args)
#define DPAA2_SEC_DP_DEBUG(fmt, ...) \
DPAA2_SEC_DP_LOG(DEBUG, fmt, ## __VA_ARGS__)
#define DPAA2_SEC_DP_INFO(fmt, ...) \
DPAA2_SEC_DP_LOG(INFO, fmt, ## __VA_ARGS__)
#define DPAA2_SEC_DP_WARN(fmt, ...) \
DPAA2_SEC_DP_LOG(WARNING, fmt, ## __VA_ARGS__)
#define DPAA2_SEC_DP_ERR(fmt, ...) \
DPAA2_SEC_DP_LOG(ERR, fmt, ## __VA_ARGS__)


#endif /* _DPAA2_SEC_LOGS_H_ */
Loading

0 comments on commit fd51012

Please sign in to comment.