From: Andre Muezerie <andremue@linux.microsoft.com>
To: Nipun Gupta <nipun.gupta@amd.com>,
Nikhil Agarwal <nikhil.agarwal@amd.com>,
Hemant Agrawal <hemant.agrawal@nxp.com>,
Sachin Saxena <sachin.saxena@nxp.com>,
Rosen Xu <rosen.xu@intel.com>,
Chengwen Feng <fengchengwen@huawei.com>
Cc: dev@dpdk.org, Andre Muezerie <andremue@linux.microsoft.com>
Subject: [PATCH 06/21] drivers/bus: use portable variadic macros
Date: Tue, 10 Dec 2024 18:05:36 -0800 [thread overview]
Message-ID: <1733882751-29598-7-git-send-email-andremue@linux.microsoft.com> (raw)
In-Reply-To: <1733882751-29598-1-git-send-email-andremue@linux.microsoft.com>
1) Use portable variadic macros
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__.
2) Add "do { } while (0)" to macros used to remove logging calls, to
ensure there's no code structure change when enabling/disabling
logging.
Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
---
drivers/bus/cdx/cdx_logs.h | 12 ++++++------
drivers/bus/dpaa/include/fman.h | 4 ++--
drivers/bus/dpaa/rte_dpaa_logs.h | 18 +++++++++---------
drivers/bus/fslmc/fslmc_logs.h | 12 ++++++------
drivers/bus/fslmc/qbman/include/compat.h | 18 +++++++++---------
drivers/bus/ifpga/ifpga_logs.h | 16 ++++++++--------
drivers/bus/uacce/uacce.c | 8 ++++----
7 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/drivers/bus/cdx/cdx_logs.h b/drivers/bus/cdx/cdx_logs.h
index 18b4010746..2d5c213417 100644
--- a/drivers/bus/cdx/cdx_logs.h
+++ b/drivers/bus/cdx/cdx_logs.h
@@ -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 */
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 01ef503117..134f0dc8ff 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -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
diff --git a/drivers/bus/dpaa/rte_dpaa_logs.h b/drivers/bus/dpaa/rte_dpaa_logs.h
index 1e61b4e76b..235c617edd 100644
--- a/drivers/bus/dpaa/rte_dpaa_logs.h
+++ b/drivers/bus/dpaa/rte_dpaa_logs.h
@@ -16,13 +16,13 @@ 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(...) \
@@ -30,11 +30,11 @@ extern int dpaa_logtype_bus;
#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_ */
diff --git a/drivers/bus/fslmc/fslmc_logs.h b/drivers/bus/fslmc/fslmc_logs.h
index ac0cd3dc29..412d160d11 100644
--- a/drivers/bus/fslmc/fslmc_logs.h
+++ b/drivers/bus/fslmc/fslmc_logs.h
@@ -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_ */
diff --git a/drivers/bus/fslmc/qbman/include/compat.h b/drivers/bus/fslmc/qbman/include/compat.h
index 4ac3254bc7..842b6c6b0a 100644
--- a/drivers/bus/fslmc/qbman/include/compat.h
+++ b/drivers/bus/fslmc/qbman/include/compat.h
@@ -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
@@ -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__; \
@@ -64,8 +64,8 @@ do { \
} \
} while (0)
#else
-#define QBMAN_BUG_ON(c) {}
-#define pr_debug(fmt, args...) {}
+#define QBMAN_BUG_ON(c) do { } while (0)
+#define pr_debug(...) do { } while (0)
#endif
/* Other miscellaneous interfaces our APIs depend on; */
diff --git a/drivers/bus/ifpga/ifpga_logs.h b/drivers/bus/ifpga/ifpga_logs.h
index 154405a590..4289d9774b 100644
--- a/drivers/bus/ifpga/ifpga_logs.h
+++ b/drivers/bus/ifpga/ifpga_logs.h
@@ -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_ */
diff --git a/drivers/bus/uacce/uacce.c b/drivers/bus/uacce/uacce.c
index c1529c38c0..9ca048122d 100644
--- a/drivers/bus/uacce/uacce.c
+++ b/drivers/bus/uacce/uacce.c
@@ -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 *
--
2.47.0.vfs.0.3
next prev parent reply other threads:[~2024-12-11 2:06 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 2:05 [PATCH 00/21] use portable variadic macros Andre Muezerie
2024-12-11 2:05 ` [PATCH 01/21] app/test-acl: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 02/21] app/test-eventdev: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 03/21] app/test-mldev: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 04/21] app/test-pmd: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 05/21] drivers/baseband: ensure code structure does not change Andre Muezerie
2024-12-11 2:05 ` Andre Muezerie [this message]
2024-12-11 2:05 ` [PATCH 07/21] drivers/common: use portable variadic macros Andre Muezerie
2024-12-11 2:05 ` [PATCH 08/21] drivers/compress: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 09/21] drivers/crypto: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 10/21] drivers/dma: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 11/21] drivers/event: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 12/21] drivers/mempool: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 13/21] drivers/net: " Andre Muezerie
2024-12-16 9:02 ` Andrew Rybchenko
2024-12-11 2:05 ` [PATCH 14/21] drivers/raw: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 15/21] drivers/vdpa: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 16/21] lib/log: ensure code structure does not change Andre Muezerie
2024-12-11 3:13 ` Stephen Hemminger
2024-12-11 16:16 ` Andre Muezerie
2024-12-11 2:05 ` [PATCH 17/21] lib/pipeline: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 18/21] lib/port: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 19/21] lib/power: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 20/21] lib/rcu: " Andre Muezerie
2024-12-11 2:05 ` [PATCH 21/21] lib/vhost: " Andre Muezerie
2024-12-11 3:14 ` [PATCH 00/21] use portable variadic macros Stephen Hemminger
2024-12-11 21:35 ` Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 00/14] " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 01/14] app/test-acl: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 02/14] app/test-eventdev: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 03/14] app/test-mldev: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 04/14] app/test-pmd: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 05/14] drivers/bus: " Andre Muezerie
2024-12-23 8:43 ` David Marchand
2024-12-11 22:07 ` [PATCH v2 06/14] drivers/common: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 07/14] drivers/compress: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 08/14] drivers/crypto: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 09/14] drivers/dma: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 10/14] drivers/event: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 11/14] drivers/mempool: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 12/14] drivers/net: " Andre Muezerie
2024-12-11 22:07 ` [PATCH v2 13/14] drivers/raw: " Andre Muezerie
2024-12-23 8:45 ` David Marchand
2024-12-11 22:07 ` [PATCH v2 14/14] drivers/vdpa: " Andre Muezerie
2024-12-23 9:28 ` [PATCH v2 00/14] " David Marchand
2024-12-23 15:39 ` Andre Muezerie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1733882751-29598-7-git-send-email-andremue@linux.microsoft.com \
--to=andremue@linux.microsoft.com \
--cc=dev@dpdk.org \
--cc=fengchengwen@huawei.com \
--cc=hemant.agrawal@nxp.com \
--cc=nikhil.agarwal@amd.com \
--cc=nipun.gupta@amd.com \
--cc=rosen.xu@intel.com \
--cc=sachin.saxena@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).