From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Shuah Khan <skhan@linuxfoundation.org>,
"Paul E. McKenney" <paulmck@kernel.org>
Cc: Willy Tarreau <w@1wt.eu>,
linux-kernel@vger.kernel.org,
Rodrigo Campos <rodrigo@sdfg.com.ar>
Subject: Re: [PATCH v3 4/4] selftests/nolibc: Add tests for strlcat() and strlcpy()
Date: Tue, 23 Apr 2024 11:18:06 +0200 [thread overview]
Message-ID: <172d25cf-cfd7-4069-8c26-df2e81ffbad1@t-8ch.de> (raw)
In-Reply-To: <20240218195110.1386840-5-rodrigo@sdfg.com.ar>
+ Shuah and Paul, please see below.
So I picked this up and it got picked up by Shuah, but...
On 2024-02-18 16:51:06+0000, Rodrigo Campos wrote:
> I've verified that the tests matches libbsd's strlcat()/strlcpy()
> implementation.
>
> Please note that as strlcat()/strlcpy() are not part of the libc, the
> tests are only compiled when using nolibc.
>
> Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
> ---
> tools/testing/selftests/nolibc/nolibc-test.c | 40 ++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 6ba4f8275ac4..d373fc14706c 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -600,6 +600,25 @@ int expect_strne(const char *expr, int llen, const char *cmp)
> return ret;
> }
>
> +#define EXPECT_STRBUFEQ(cond, expr, buf, val, cmp) \
> + do { if (!(cond)) result(llen, SKIPPED); else ret += expect_str_buf_eq(expr, buf, val, llen, cmp); } while (0)
> +
> +static __attribute__((unused))
> +int expect_str_buf_eq(size_t expr, const char *buf, size_t val, int llen, const char *cmp)
> +{
> + llen += printf(" = %lu <%s> ", expr, buf);
This introduces a compiler warning on 32bit:
i386-linux-gcc -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra -fno-stack-protector -m32 -mstack-protector-guard=global -fstack-protector-all -o nolibc-test \
-nostdlib -nostdinc -static -Isysroot/i386/include nolibc-test.c nolibc-test-linkage.c -lgcc
nolibc-test.c: In function 'expect_str_buf_eq':
nolibc-test.c:610:30: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
610 | llen += printf(" = %lu <%s> ", expr, buf);
| ~~^ ~~~~
| | |
| | size_t {aka unsigned int}
| long unsigned int
| %u
It is easy enough to fix through a cast to "unsigned long".
The original patch was already sent to Shuah and included in -next.
Shuah, Paul:
I'd like to rewrite the offending commit instead of having a fixup commit.
As it seems to me the original patch would only go into 6.10 anyways.
Any objections?
Notes to self:
* Add flag to run-tests.sh to use -Werror
* Implement "%zu" in nolibc printf()
> + if (strcmp(buf, cmp) != 0) {
> + result(llen, FAIL);
> + return 1;
> + }
> + if (expr != val) {
> + result(llen, FAIL);
> + return 1;
> + }
> +
> + result(llen, OK);
> + return 0;
> +}
> [..]
next prev parent reply other threads:[~2024-04-23 9:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-18 19:51 [PATCH v3 0/4] Misc fixes for strlcpy() and strlcat() Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 1/4] tools/nolibc/string: export strlen() Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 2/4] tools/nolibc: Fix strlcat() return code and size usage Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 3/4] tools/nolibc: Fix strlcpy() " Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 4/4] selftests/nolibc: Add tests for strlcat() and strlcpy() Rodrigo Campos
2024-02-18 20:39 ` Rodrigo Campos
2024-02-18 21:11 ` Willy Tarreau
2024-02-18 21:41 ` Rodrigo Campos
2024-04-23 9:18 ` Thomas Weißschuh [this message]
2024-04-23 16:28 ` Willy Tarreau
2024-04-23 19:49 ` Paul E. McKenney
2024-04-26 16:43 ` Rodrigo Campos
2024-02-19 20:48 ` [PATCH v3 0/4] Misc fixes for strlcpy() and strlcat() Willy Tarreau
2024-02-20 19:25 ` Rodrigo Campos
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=172d25cf-cfd7-4069-8c26-df2e81ffbad1@t-8ch.de \
--to=linux@weissschuh.net \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rodrigo@sdfg.com.ar \
--cc=skhan@linuxfoundation.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®