From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF63A45E6F; Wed, 11 Dec 2024 03:06:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E3A44065C; Wed, 11 Dec 2024 03:06:24 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 2B60E40616 for ; Wed, 11 Dec 2024 03:06:16 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1213) id 629992047230; Tue, 10 Dec 2024 18:06:15 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 629992047230 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1733882775; bh=JDBPc9JLEjNYp3KXTRv6BSvA/QEdE4AnumI5yTXOVpk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fAcYfUyO/ix8qFsp6awB/+8kjxRz4yqpXmvxrfMJZAgEtN+iBi3WPr2oZ4UI7BI9g p3WI1n8hdKPmQrLPwgPYu19S8AWc8pZojsYY3Mzl9eS6U4YDp8ROwcRWT4WJHQ0T2j hQP6bLNLElXBfnoWqGSlBLiouRfRbAAYgevUBXXU= From: Andre Muezerie To: Hemant Agrawal , Sachin Saxena , Jingjing Wu , Praveen Shetty Cc: dev@dpdk.org, Andre Muezerie Subject: [PATCH 07/21] drivers/common: use portable variadic macros Date: Tue, 10 Dec 2024 18:05:37 -0800 Message-Id: <1733882751-29598-8-git-send-email-andremue@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1733882751-29598-1-git-send-email-andremue@linux.microsoft.com> References: <1733882751-29598-1-git-send-email-andremue@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- drivers/common/dpaax/compat.h | 16 ++++++++-------- drivers/common/dpaax/dpaax_logs.h | 18 +++++++++--------- drivers/common/idpf/base/idpf_osdep.h | 8 +++++--- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/common/dpaax/compat.h b/drivers/common/dpaax/compat.h index 7c8d82c2b2..1b80ba6cef 100644 --- a/drivers/common/dpaax/compat.h +++ b/drivers/common/dpaax/compat.h @@ -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, ...) do { } while (0) #endif #endif diff --git a/drivers/common/dpaax/dpaax_logs.h b/drivers/common/dpaax/dpaax_logs.h index 6ed29fb2ea..90f0c98863 100644 --- a/drivers/common/dpaax/dpaax_logs.h +++ b/drivers/common/dpaax/dpaax_logs.h @@ -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, ...) \ @@ -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_ */ diff --git a/drivers/common/idpf/base/idpf_osdep.h b/drivers/common/idpf/base/idpf_osdep.h index cf9e553906..250f0ec500 100644 --- a/drivers/common/idpf/base/idpf_osdep.h +++ b/drivers/common/idpf/base/idpf_osdep.h @@ -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) @@ -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; \ -- 2.47.0.vfs.0.3