]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/nolibc: Return correct value when printf test fails
authorDavid Laight <david.laight.linux@gmail.com>
Mon, 2 Mar 2026 10:17:55 +0000 (10:17 +0000)
committerThomas Weißschuh <linux@weissschuh.net>
Fri, 20 Mar 2026 16:46:01 +0000 (17:46 +0100)
Correctly return 1 (the number of errors) when strcmp()
fails rather than the return value from strncmp() which is the
signed difference between the mismatching characters.

Signed-off-by: David Laight <david.laight.linux@gmail.com>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://patch.msgid.link/20260302101815.3043-4-david.laight.linux@gmail.com
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
tools/testing/selftests/nolibc/nolibc-test.c

index 801b2ad188537e989723ba52329a1f1586851576..7588212df124852998b82962993975ca399bd3cc 100644 (file)
@@ -1691,7 +1691,7 @@ static int expect_vfprintf(int llen, int c, const char *expected, const char *fm
        }
 
        llen += printf(" \"%s\" = \"%s\"", expected, buf);
-       ret = strncmp(expected, buf, c);
+       ret = strncmp(expected, buf, c) != 0;
 
        result(llen, ret ? FAIL : OK);
        return ret;