All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib: TST_EXP_FAIL: Fix the *_ARR_() macros
@ 2024-01-17 10:18 Cyril Hrubis
  2024-01-17 11:07 ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2024-01-17 10:18 UTC (permalink / raw)
  To: ltp

This is basically the same fix as:
d7e5e102364b (tst_test_macros.h: fix "too many arguments")

The point is that the SCALL parameter has to be stringified in the first
pass otherwise it ends up expandend and as long as it contains coma the
number of parameters will increase breaking the printf() formatting
again.

Fixes: #1120

Fixes: 1cfe61428982 ("lib: TST_EXP_FAIL: Add array variants")
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_test_macros.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
index 24fd324bf..d2e50a219 100644
--- a/include/tst_test_macros.h
+++ b/include/tst_test_macros.h
@@ -227,41 +227,41 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt);
 		}                                                              \
 	} while (0)
 
-#define TST_EXP_FAIL_ARR_(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)                  \
+#define TST_EXP_FAIL_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)          \
 	do {                                                                   \
-		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, #SCALL,              \
+		TST_EXP_FAIL_SILENT_(TST_RET == 0, SCALL, SSCALL,              \
 			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);                \
 		if (TST_PASS)                                                  \
-			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+			TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \
 	} while (0)
 
 #define TST_EXP_FAIL(SCALL, EXP_ERR, ...)                                      \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
-		TST_EXP_FAIL_ARR_(SCALL, &tst_exp_err__, 1,                    \
+		TST_EXP_FAIL_ARR_(SCALL, #SCALL, &tst_exp_err__, 1,            \
                                   ##__VA_ARGS__);                              \
 	} while (0)
 
 #define TST_EXP_FAIL_ARR(SCALL, EXP_ERRS, ...)                                 \
-		TST_EXP_FAIL_ARR_(SCALL, EXP_ERRS, ARRAY_SIZE(EXP_ERRS),       \
-                                  ##__VA_ARGS__);                              \
+		TST_EXP_FAIL_ARR_(SCALL, #SCALL, EXP_ERRS,                     \
+				  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
-#define TST_EXP_FAIL2_ARR_(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...)                 \
+#define TST_EXP_FAIL2_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...)         \
 	do {                                                                   \
-		TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, #SCALL,              \
+		TST_EXP_FAIL_SILENT_(TST_RET >= 0, SCALL, SSCALL,              \
 			EXP_ERRS, EXP_ERRS_CNT, ##__VA_ARGS__);                \
 		if (TST_PASS)                                                  \
-			TST_MSG_(TPASS | TTERRNO, " ", #SCALL, ##__VA_ARGS__); \
+			TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \
 	} while (0)
 
 #define TST_EXP_FAIL2_ARR(SCALL, EXP_ERRS, ...)                                \
-		TST_EXP_FAIL2_ARR_(SCALL, EXP_ERRS, ARRAY_SIZE(EXP_ERRS),      \
-                                  ##__VA_ARGS__);                              \
+		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS,                    \
+		                  ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__);
 
 #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...)                                     \
 	do {                                                                   \
 		int tst_exp_err__ = EXP_ERR;                                   \
-		TST_EXP_FAIL2_ARR_(SCALL, &tst_exp_err__, 1,                   \
+		TST_EXP_FAIL2_ARR_(SCALL, #SCALL, &tst_exp_err__, 1,           \
                                   ##__VA_ARGS__);                              \
 	} while (0)
 
-- 
2.43.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-17 11:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-17 10:18 [LTP] [PATCH] lib: TST_EXP_FAIL: Fix the *_ARR_() macros Cyril Hrubis
2024-01-17 11:07 ` Petr Vorel
2024-01-17 11:41   ` Cyril Hrubis
2024-01-17 11:44     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.