Use an array of strings instead of pointer smuggling
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
diff --git a/tests/suites/test_suite_debug.function b/tests/suites/test_suite_debug.function
index ed3505a..15605c7 100644
--- a/tests/suites/test_suite_debug.function
+++ b/tests/suites/test_suite_debug.function
@@ -7,6 +7,16 @@
# include <crtdbg.h>
#endif
+typedef enum {
+ PRINTF_SIZET,
+ PRINTF_LONGLONG,
+} printf_format_indicator_t;
+
+const char *const printf_formats[] = {
+ [PRINTF_SIZET] = "%" MBEDTLS_PRINTF_SIZET,
+ [PRINTF_LONGLONG] = "%" MBEDTLS_PRINTF_LONGLONG,
+};
+
struct buffer_data {
char buf[2000];
char *ptr;
@@ -74,8 +84,7 @@
*/
/* BEGIN_CASE */
-void printf_int_expr(intmax_t smuggle_format_expr, /* TODO: teach test framework about string expressions */
- intmax_t sizeof_x, intmax_t x, char *result)
+void printf_int_expr(int format_indicator, intmax_t sizeof_x, intmax_t x, char *result)
{
#if defined(_WIN32)
/* Windows treats any invalid format specifiers passsed to the CRT as fatal assertion failures.
@@ -88,7 +97,7 @@
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
#endif
- const char *format = (char *) ((uintptr_t) smuggle_format_expr);
+ const char *format = printf_formats[format_indicator];
char *output = NULL;
const size_t n = strlen(result);