This is a note to let you know that I've just added the patch titled selftests/nolibc: avoid passing NULL to printf("%s") to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: selftests-nolibc-avoid-passing-null-to-printf-s.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit a7ff3bb179227f57faaebc53e984e2bb8ef459b5 Author: Thomas Weißschuh <linux@xxxxxxxxxxxxxx> Date: Wed Aug 7 23:51:44 2024 +0200 selftests/nolibc: avoid passing NULL to printf("%s") [ Upstream commit f1a58f61d88642ae1e6e97e9d72d73bc70a93cb8 ] Clang on higher optimization levels detects that NULL is passed to printf("%s") and warns about it. While printf() from nolibc gracefully handles that NULL, it is undefined behavior as per POSIX, so the warning is reasonable. Avoid the warning by transforming NULL into a non-NULL placeholder. Reviewed-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx> Acked-by: Willy Tarreau <w@xxxxxx> Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-8-c20f2f5fc7c2@xxxxxxxxxxxxxx Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index f8e8e8d2a5e18..c6ef8b3e83458 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -353,7 +353,7 @@ static int expect_strzr(const char *expr, int llen) { int ret = 0; - llen += printf(" = <%s> ", expr); + llen += printf(" = <%s> ", expr ? expr : "(null)"); if (expr) { ret = 1; llen += pad_spc(llen, 40, "[FAIL]\n"); @@ -371,7 +371,7 @@ static int expect_strnz(const char *expr, int llen) { int ret = 0; - llen += printf(" = <%s> ", expr); + llen += printf(" = <%s> ", expr ? expr : "(null)"); if (!expr) { ret = 1; llen += pad_spc(llen, 40, "[FAIL]\n");