[LTP] [PATCH] tst_test_macros.h: fix "too many arguments"

Shiyang Ruan ruansy.fnst@fujitsu.com
Tue Jan 9 10:03:04 CET 2024


While calling TST_EXP_FD_SILENT() and TST_EXP_PID_SILENT(), their
defined function TST_EXP_POSITIVE_() should pass its SSCALL to
TST_EXP_POSITIVE__(), instead of creating a new one.  This fix makes
error message look correct, and also can eliminate build warnings, such
as:

dup3_01.c:43:83: warning: too many arguments for format [-Wformat-extra-args]
   43 |         TST_EXP_FD_SILENT(dup3(1, 4, tc->coe_flag), "dup3(1, 4, %d)", tc->coe_flag);
      |                                                                                   ^
../../../../include/tst_test_macros.h:40:32: note: in definition of macro ‘TST_FMT_’
   40 | #define TST_FMT_(FMT, _1, ...) FMT, ##__VA_ARGS__
      |                                ^~~
../../../../include/tst_test_macros.h:44:26: note: in expansion of macro ‘TST_2_’
   44 |                 TST_FMT_(TST_2_(dummy, ##__VA_ARGS__, SCALL) FMT, __VA_ARGS__))
      |                          ^~~~~~
../../../../include/tst_test_macros.h:61:25: note: in expansion of macro ‘TST_MSG_’
   61 |                         TST_MSG_(TFAIL | TTERRNO, " failed",                   \
      |                         ^~~~~~~~
../../../../include/tst_test_macros.h:78:17: note: in expansion of macro ‘TST_EXP_POSITIVE__’
   78 |                 TST_EXP_POSITIVE__(SCALL, #SCALL, ##__VA_ARGS__);              \
      |                 ^~~~~~~~~~~~~~~~~~
../../../../include/tst_test_macros.h:94:41: note: in expansion of macro ‘TST_EXP_POSITIVE_’
   94 | #define TST_EXP_FD_SILENT(SCALL, ...)   TST_EXP_POSITIVE_(SCALL, #SCALL, ##__VA_ARGS__)
      |                                         ^~~~~~~~~~~~~~~~~
dup3_01.c:43:9: note: in expansion of macro ‘TST_EXP_FD_SILENT’
   43 |         TST_EXP_FD_SILENT(dup3(1, 4, tc->coe_flag), "dup3(1, 4, %d)", tc->coe_flag);
      |         ^~~~~~~~~~~~~~~~~

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 include/tst_test_macros.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index bd0c491c1..3f4f9f11d 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -73,9 +73,9 @@ extern void *TST_RET_PTR;
                                                                                \
 	} while (0)
 
-#define TST_EXP_POSITIVE_(SCALL, ...)                                          \
+#define TST_EXP_POSITIVE_(SCALL, SSCALL, ...)                                  \
 	({                                                                     \
-		TST_EXP_POSITIVE__(SCALL, #SCALL, ##__VA_ARGS__);              \
+		TST_EXP_POSITIVE__(SCALL, SSCALL, ##__VA_ARGS__);              \
 		TST_RET;                                                       \
 	})
 
-- 
2.34.1



More information about the ltp mailing list