tools/nolibc: tests: fix build on non-c99 compliant compilers
authorWilly Tarreau <w@1wt.eu>
Sun, 2 Apr 2023 08:13:56 +0000 (10:13 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 9 Jun 2023 18:33:04 +0000 (11:33 -0700)
Commit 9735716830f2 ("tools/nolibc: tests: add test for -fstack-protector")
brought a declaration inside the initialization statement of a for loop,
which breaks the build on compilers that do not default to c99
compatibility, making it more difficult to validate that the lib still
builds on such compilers. The fix is trivial, so let's move the
declaration to the variables block of the function instead. No backport
is needed.

Cc: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/nolibc/nolibc-test.c

index 47013b78972e532f76a600913ddf0b85e0538f10..6f2f109569a3c266fe00d2884ac4dcae6340fee7 100644 (file)
@@ -671,8 +671,9 @@ static int smash_stack(void)
 {
        char buf[100];
        volatile char *ptr = buf;
+       size_t i;
 
-       for (size_t i = 0; i < 200; i++)
+       for (i = 0; i < 200; i++)
                ptr[i] = 'P';
 
        return 1;