[04/15] cmdline: use GCC and MSVC common VA ARGS extension

Message ID 1707774557-16012-5-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.

Fix checkpatches warning about style while(0) -> while (0)

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/cmdline/cmdline_parse.c     | 2 +-
 lib/cmdline/cmdline_parse_num.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Bruce Richardson Feb. 13, 2024, 9:04 a.m. UTC | #1
On Mon, Feb 12, 2024 at 01:49:06PM -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.
> 
> Fix checkpatches warning about style while(0) -> while (0)
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
  

Patch

diff --git a/lib/cmdline/cmdline_parse.c b/lib/cmdline/cmdline_parse.c
index b6d6dac..76a212d 100644
--- a/lib/cmdline/cmdline_parse.c
+++ b/lib/cmdline/cmdline_parse.c
@@ -16,7 +16,7 @@ 
 #ifdef RTE_LIBRTE_CMDLINE_DEBUG
 #define debug_printf printf
 #else
-#define debug_printf(args...) do {} while(0)
+#define debug_printf(...) do {} while (0)
 #endif
 
 #define CMDLINE_BUFFER_SIZE 64
diff --git a/lib/cmdline/cmdline_parse_num.c b/lib/cmdline/cmdline_parse_num.c
index 820af07..e849878 100644
--- a/lib/cmdline/cmdline_parse_num.c
+++ b/lib/cmdline/cmdline_parse_num.c
@@ -14,9 +14,9 @@ 
 #include "cmdline_parse_num.h"
 
 #ifdef RTE_LIBRTE_CMDLINE_DEBUG
-#define debug_printf(args...) printf(args)
+#define debug_printf(...) printf(__VA_ARGS__)
 #else
-#define debug_printf(args...) do {} while(0)
+#define debug_printf(...) do {} while (0)
 #endif
 
 struct cmdline_token_ops cmdline_token_num_ops = {