[PATCH v4 01/14] tests/tcg/minilib: Constify digits in print_num

Richard Henderson posted 14 patches 2 months, 2 weeks ago
Maintainers: Laurent Vivier <laurent@vivier.eu>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Peter Maydell <peter.maydell@linaro.org>
[PATCH v4 01/14] tests/tcg/minilib: Constify digits in print_num
Posted by Richard Henderson 2 months, 2 weeks ago
This avoids a memcpy to the stack when compiled with clang.
Since we don't enable optimization, nor provide memcpy,
this results in an undefined symbol error at link time.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/minilib/printf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tcg/minilib/printf.c b/tests/tcg/minilib/printf.c
index 10472b4f58..fb0189c2bb 100644
--- a/tests/tcg/minilib/printf.c
+++ b/tests/tcg/minilib/printf.c
@@ -27,7 +27,7 @@ static void print_str(char *s)
 
 static void print_num(unsigned long long value, int base)
 {
-    char digits[] = "0123456789abcdef";
+    static const char digits[] = "0123456789abcdef";
     char buf[32];
     int i = sizeof(buf) - 2, j;
 
-- 
2.34.1
Re: [PATCH v4 01/14] tests/tcg/minilib: Constify digits in print_num
Posted by Philippe Mathieu-Daudé 2 months, 2 weeks ago
On 30/6/24 21:00, Richard Henderson wrote:
> This avoids a memcpy to the stack when compiled with clang.
> Since we don't enable optimization, nor provide memcpy,
> this results in an undefined symbol error at link time.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tests/tcg/minilib/printf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>