From: david.laight.linux@gmail.com
To: "Willy Tarreau" <w@1wt.eu>,
"Thomas Weißschuh" <linux@weissschuh.net>,
linux-kernel@vger.kernel.org, "Cheng Li" <lechain@gmail.com>
Cc: David Laight <david.laight.linux@gmail.com>
Subject: [PATCH] selftests/nolibc: Fix build with host headers and libc
Date: Sat, 14 Feb 2026 11:57:24 +0000 [thread overview]
Message-ID: <20260214115724.3305-1-david.laight.linux@gmail.com> (raw)
From: David Laight <david.laight.linux@gmail.com>
Many systems don't have strlcpy() or strlcat().
Change is_nolibc to a #define so that the calls are optimised out.
Create #define wrappers so the code is syntactially valid.
Additionall readdir_r() is likely to be marked deprecated.
So disable "-Wdeprecated-declarations".
Fixes: 6fe8360b16acb ("selftests/nolibc: also test libc-test through regular selftest framework")
Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
tools/testing/selftests/nolibc/nolibc-test.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 1b9d3b2e2491..eb2421b42e75 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -66,13 +66,18 @@ static const char *argv0;
/* will be used by constructor tests */
static int constructor_test_value;
-static const int is_nolibc =
#ifdef NOLIBC
- 1
+#define is_nolibc 1
#else
- 0
+#define is_nolibc 0
+/* strlcat() and strlcpy() may not be in the system headers. */
+#undef strlcat
+#undef strlcpy
+#define strlcat(d, s, l) 0
+#define strlcpy(d, s, l) 0
+/* readdir_r() is likely to be marked deprecated */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
-;
/* definition of a series of tests */
struct test {
--
2.39.5
next reply other threads:[~2026-02-14 11:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-14 11:57 david.laight.linux [this message]
2026-02-16 18:51 ` [PATCH] selftests/nolibc: Fix build with host headers and libc Thomas Weißschuh
2026-02-16 22:21 ` David Laight
2026-02-18 17:23 ` Thomas Weißschuh
2026-02-18 22:51 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260214115724.3305-1-david.laight.linux@gmail.com \
--to=david.laight.linux@gmail.com \
--cc=lechain@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.