[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240925115823.1303019-92-sashal@kernel.org>
Date: Wed, 25 Sep 2024 07:51:51 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
Shuah Khan <skhan@...uxfoundation.org>,
Willy Tarreau <w@....eu>,
Sasha Levin <sashal@...nel.org>,
shuah@...nel.org,
nathan@...nel.org,
linux-kselftest@...r.kernel.org,
llvm@...ts.linux.dev
Subject: [PATCH AUTOSEL 6.10 092/197] selftests/nolibc: avoid passing NULL to printf("%s")
From: Thomas Weißschuh <linux@...ssschuh.net>
[ 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@...uxfoundation.org>
Acked-by: Willy Tarreau <w@....eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-8-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
tools/testing/selftests/nolibc/nolibc-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 994477ee87bef..4bd8360d54225 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -534,7 +534,7 @@ 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;
result(llen, FAIL);
@@ -553,7 +553,7 @@ 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;
result(llen, FAIL);
--
2.43.0
Powered by blists - more mailing lists