[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQKTnS-EH=d58JEWEey5LGEeMx==_UHW6e2-kTbgp+ci5A@mail.gmail.com>
Date: Mon, 17 Mar 2025 09:54:51 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: feng.wei8@....com.cn
Cc: Andrii Nakryiko <andrii@...nel.org>, Eddy Z <eddyz87@...il.com>,
Mykola Lysenko <mykolal@...com>, Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>, bpf <bpf@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK" <linux-kselftest@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] selftests/bpf: Replace deprecated strncpy() with strscpy()
On Mon, Mar 17, 2025 at 12:47 AM <feng.wei8@....com.cn> wrote:
>
> From: FengWei <feng.wei8@....com.cn>
>
> strncpy() is deprecated for NUL-terminated destination buffers. Use
> strscpy() instead and remove the manual NUL-termination.
>
> Signed-off-by: FengWei <feng.wei8@....com.cn>
> ---
> tools/testing/selftests/bpf/test_verifier.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
> index 447b68509d76..dfe64c6d4f87 100644
> --- a/tools/testing/selftests/bpf/test_verifier.c
> +++ b/tools/testing/selftests/bpf/test_verifier.c
> @@ -1320,8 +1320,7 @@ static bool cmp_str_seq(const char *log, const char *exp)
> printf("FAIL\nTestcase bug\n");
> return false;
> }
> - strncpy(needle, exp, len);
> - needle[len] = 0;
> + strscpy(needle, exp, len);
Pls do not send patches that were not even build tested.
test_verifier.c:1323:3: error: call to undeclared function 'strscpy';
ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]
1323 | strscpy(needle, exp, len);
1 error generated.
pw-bot: cr
Powered by blists - more mailing lists