[03/15] cfgfile: use GCC and MSVC common VA ARGS extension

Message ID 1707774557-16012-4-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series use GCC/MSVC compatible __VA_ARGS__ |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Tyler Retzlaff Feb. 12, 2024, 9:49 p.m. UTC
  Use ... and forward with __VA_ARGS__ instead of args... and args.
Neither mechanism is conformant with the standard but the former works
with both GCC and MSVC.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/cfgfile/rte_cfgfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Bruce Richardson Feb. 13, 2024, 9:03 a.m. UTC | #1
On Mon, Feb 12, 2024 at 01:49:05PM -0800, Tyler Retzlaff wrote:
> Use ... and forward with __VA_ARGS__ instead of args... and args.
> Neither mechanism is conformant with the standard but the former works
> with both GCC and MSVC.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  lib/cfgfile/rte_cfgfile.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/cfgfile/rte_cfgfile.c b/lib/cfgfile/rte_cfgfile.c
> index 6a5e4fd..e006508 100644
> --- a/lib/cfgfile/rte_cfgfile.c
> +++ b/lib/cfgfile/rte_cfgfile.c
> @@ -31,8 +31,8 @@ struct rte_cfgfile {
>  RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
>  #define RTE_LOGTYPE_CFGFILE cfgfile_logtype
>  
> -#define CFG_LOG(level, fmt, args...)					\
> -	RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args)
> +#define CFG_LOG(level, fmt, ...)					\
> +	RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## __VA_ARGS__)
>  /* >8 End of setting up dynamic logging */
>  

Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
  

Patch

diff --git a/lib/cfgfile/rte_cfgfile.c b/lib/cfgfile/rte_cfgfile.c
index 6a5e4fd..e006508 100644
--- a/lib/cfgfile/rte_cfgfile.c
+++ b/lib/cfgfile/rte_cfgfile.c
@@ -31,8 +31,8 @@  struct rte_cfgfile {
 RTE_LOG_REGISTER_DEFAULT(cfgfile_logtype, INFO);
 #define RTE_LOGTYPE_CFGFILE cfgfile_logtype
 
-#define CFG_LOG(level, fmt, args...)					\
-	RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## args)
+#define CFG_LOG(level, fmt, ...)					\
+	RTE_LOG_LINE(level, CFGFILE, "%s(): " fmt, __func__, ## __VA_ARGS__)
 /* >8 End of setting up dynamic logging */
 
 /** when we resize a file structure, how many extra entries