* [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14
@ 2025-06-17 4:49 Yonghong Song
2025-06-17 17:24 ` Alexei Starovoitov
2025-06-17 18:15 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Yonghong Song @ 2025-06-17 4:49 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team,
Martin KaFai Lau
With gcc14, when building with RELEASE=1, I hit four below compilation
failure:
Error 1:
In file included from test_loader.c:6:
test_loader.c: In function ‘run_subtest’: test_progs.h:194:17:
error: ‘retval’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
194 | fprintf(stdout, ##format); \
| ^~~~~~~
test_loader.c:958:13: note: ‘retval’ was declared here
958 | int retval, err, i;
| ^~~~~~
The uninitialized var 'retval' actaully could cause incorrect result.
Error 2:
In function ‘test_fd_array_cnt’:
prog_tests/fd_array.c:71:14: error: ‘btf_id’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
71 | fd = bpf_btf_get_fd_by_id(id);
| ^~~~~~~~~~~~~~~~~~~~~~~~
prog_tests/fd_array.c:302:15: note: ‘btf_id’ was declared here
302 | __u32 btf_id;
| ^~~~~~
Changing ASSERT_GE to ASSERT_EQ can fix the compilation error. Otherwise,
there is no functionality change.
Error 3:
prog_tests/tailcalls.c: In function ‘test_tailcall_hierarchy_count’:
prog_tests/tailcalls.c:1402:23: error: ‘fentry_data_fd’ may be used uninitialized
in this function [-Werror=maybe-uninitialized]
1402 | err = bpf_map_lookup_elem(fentry_data_fd, &i, &val);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The code is correct. The change intends to slient gcc errors.
Error 4: (this error only happens on arm64)
In file included from prog_tests/log_buf.c:4:
prog_tests/log_buf.c: In function ‘bpf_prog_load_log_buf’:
./test_progs.h:390:22: error: ‘log_buf’ may be used uninitialized [-Werror=maybe-uninitialized]
390 | int ___err = libbpf_get_error(___res); \
| ^~~~~~~~~~~~~~~~~~~~~~~~
prog_tests/log_buf.c:158:14: note: in expansion of macro ‘ASSERT_OK_PTR’
158 | if (!ASSERT_OK_PTR(log_buf, "log_buf_alloc"))
| ^~~~~~~~~~~~~
In file included from selftests/bpf/tools/include/bpf/bpf.h:32,
from ./test_progs.h:36:
selftests/bpf/tools/include/bpf/libbpf_legacy.h:113:17:
note: by argument 1 of type ‘const void *’ to ‘libbpf_get_error’ declared here
113 | LIBBPF_API long libbpf_get_error(const void *ptr);
| ^~~~~~~~~~~~~~~~
Adding a pragma to disable maybe-uninitialized fixed the issue.
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
tools/testing/selftests/bpf/prog_tests/fd_array.c | 2 +-
tools/testing/selftests/bpf/prog_tests/log_buf.c | 4 ++++
tools/testing/selftests/bpf/prog_tests/tailcalls.c | 2 +-
tools/testing/selftests/bpf/test_loader.c | 6 +++---
4 files changed, 9 insertions(+), 5 deletions(-)
NOTE: I found these issues when I tried to compare usdt.test.o binaries
when building selftests with and without RELEASE=1.
diff --git a/tools/testing/selftests/bpf/prog_tests/fd_array.c b/tools/testing/selftests/bpf/prog_tests/fd_array.c
index 9add890c2d37..241b2c8c6e0f 100644
--- a/tools/testing/selftests/bpf/prog_tests/fd_array.c
+++ b/tools/testing/selftests/bpf/prog_tests/fd_array.c
@@ -312,7 +312,7 @@ static void check_fd_array_cnt__referenced_btfs(void)
/* btf should still exist when original file descriptor is closed */
err = get_btf_id_by_fd(extra_fds[0], &btf_id);
- if (!ASSERT_GE(err, 0, "get_btf_id_by_fd"))
+ if (!ASSERT_EQ(err, 0, "get_btf_id_by_fd"))
goto cleanup;
Close(extra_fds[0]);
diff --git a/tools/testing/selftests/bpf/prog_tests/log_buf.c b/tools/testing/selftests/bpf/prog_tests/log_buf.c
index 169ce689b97c..d6f14a232002 100644
--- a/tools/testing/selftests/bpf/prog_tests/log_buf.c
+++ b/tools/testing/selftests/bpf/prog_tests/log_buf.c
@@ -7,6 +7,10 @@
#include "test_log_buf.skel.h"
#include "bpf_util.h"
+#if !defined(__clang__)
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
+#endif
+
static size_t libbpf_log_pos;
static char libbpf_log_buf[1024 * 1024];
static bool libbpf_log_error;
diff --git a/tools/testing/selftests/bpf/prog_tests/tailcalls.c b/tools/testing/selftests/bpf/prog_tests/tailcalls.c
index 66a900327f91..0ab36503c3b2 100644
--- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c
+++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c
@@ -1195,7 +1195,7 @@ static void test_tailcall_hierarchy_count(const char *which, bool test_fentry,
bool test_fexit,
bool test_fentry_entry)
{
- int err, map_fd, prog_fd, main_data_fd, fentry_data_fd, fexit_data_fd, i, val;
+ int err, map_fd, prog_fd, main_data_fd, fentry_data_fd = 0, fexit_data_fd = 0, i, val;
struct bpf_object *obj = NULL, *fentry_obj = NULL, *fexit_obj = NULL;
struct bpf_link *fentry_link = NULL, *fexit_link = NULL;
struct bpf_program *prog, *fentry_prog;
diff --git a/tools/testing/selftests/bpf/test_loader.c b/tools/testing/selftests/bpf/test_loader.c
index 9551d8d5f8f9..2c7e9729d5fe 100644
--- a/tools/testing/selftests/bpf/test_loader.c
+++ b/tools/testing/selftests/bpf/test_loader.c
@@ -1103,9 +1103,9 @@ void run_subtest(struct test_loader *tester,
}
}
- do_prog_test_run(bpf_program__fd(tprog), &retval,
- bpf_program__type(tprog) == BPF_PROG_TYPE_SYSCALL ? true : false);
- if (retval != subspec->retval && subspec->retval != POINTER_VALUE) {
+ err = do_prog_test_run(bpf_program__fd(tprog), &retval,
+ bpf_program__type(tprog) == BPF_PROG_TYPE_SYSCALL ? true : false);
+ if (!err && retval != subspec->retval && subspec->retval != POINTER_VALUE) {
PRINT_FAIL("Unexpected retval: %d != %d\n", retval, subspec->retval);
goto tobj_cleanup;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14
2025-06-17 4:49 [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14 Yonghong Song
@ 2025-06-17 17:24 ` Alexei Starovoitov
2025-06-17 22:09 ` Yonghong Song
2025-06-17 18:15 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2025-06-17 17:24 UTC (permalink / raw)
To: Yonghong Song
Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
Kernel Team, Martin KaFai Lau
On Mon, Jun 16, 2025 at 9:50 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
> With gcc14, when building with RELEASE=1, I hit four below compilation
> failure:
>
> Error 1:
> In file included from test_loader.c:6:
> test_loader.c: In function ‘run_subtest’: test_progs.h:194:17:
> error: ‘retval’ may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
> 194 | fprintf(stdout, ##format); \
> | ^~~~~~~
> test_loader.c:958:13: note: ‘retval’ was declared here
> 958 | int retval, err, i;
> | ^~~~~~
>
> The uninitialized var 'retval' actaully could cause incorrect result.
actually
> Error 2:
> In function ‘test_fd_array_cnt’:
> prog_tests/fd_array.c:71:14: error: ‘btf_id’ may be used uninitialized in this
> function [-Werror=maybe-uninitialized]
> 71 | fd = bpf_btf_get_fd_by_id(id);
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> prog_tests/fd_array.c:302:15: note: ‘btf_id’ was declared here
> 302 | __u32 btf_id;
> | ^~~~~~
>
> Changing ASSERT_GE to ASSERT_EQ can fix the compilation error. Otherwise,
> there is no functionality change.
>
> Error 3:
> prog_tests/tailcalls.c: In function ‘test_tailcall_hierarchy_count’:
> prog_tests/tailcalls.c:1402:23: error: ‘fentry_data_fd’ may be used uninitialized
> in this function [-Werror=maybe-uninitialized]
> 1402 | err = bpf_map_lookup_elem(fentry_data_fd, &i, &val);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> The code is correct. The change intends to slient gcc errors.
to silence.
Fixed the typos while applying.
Pls use spell check.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14
2025-06-17 4:49 [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14 Yonghong Song
2025-06-17 17:24 ` Alexei Starovoitov
@ 2025-06-17 18:15 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-06-17 18:15 UTC (permalink / raw)
To: Yonghong Song; +Cc: bpf, ast, andrii, daniel, kernel-team, martin.lau
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Mon, 16 Jun 2025 21:49:56 -0700 you wrote:
> With gcc14, when building with RELEASE=1, I hit four below compilation
> failure:
>
> Error 1:
> In file included from test_loader.c:6:
> test_loader.c: In function ‘run_subtest’: test_progs.h:194:17:
> error: ‘retval’ may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
> 194 | fprintf(stdout, ##format); \
> | ^~~~~~~
> test_loader.c:958:13: note: ‘retval’ was declared here
> 958 | int retval, err, i;
> | ^~~~~~
>
> [...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14
https://git.kernel.org/bpf/bpf-next/c/a633dab4b4d2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14
2025-06-17 17:24 ` Alexei Starovoitov
@ 2025-06-17 22:09 ` Yonghong Song
0 siblings, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2025-06-17 22:09 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
Kernel Team, Martin KaFai Lau
On 6/17/25 10:24 AM, Alexei Starovoitov wrote:
> On Mon, Jun 16, 2025 at 9:50 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>> With gcc14, when building with RELEASE=1, I hit four below compilation
>> failure:
>>
>> Error 1:
>> In file included from test_loader.c:6:
>> test_loader.c: In function ‘run_subtest’: test_progs.h:194:17:
>> error: ‘retval’ may be used uninitialized in this function
>> [-Werror=maybe-uninitialized]
>> 194 | fprintf(stdout, ##format); \
>> | ^~~~~~~
>> test_loader.c:958:13: note: ‘retval’ was declared here
>> 958 | int retval, err, i;
>> | ^~~~~~
>>
>> The uninitialized var 'retval' actaully could cause incorrect result.
> actually
>
>> Error 2:
>> In function ‘test_fd_array_cnt’:
>> prog_tests/fd_array.c:71:14: error: ‘btf_id’ may be used uninitialized in this
>> function [-Werror=maybe-uninitialized]
>> 71 | fd = bpf_btf_get_fd_by_id(id);
>> | ^~~~~~~~~~~~~~~~~~~~~~~~
>> prog_tests/fd_array.c:302:15: note: ‘btf_id’ was declared here
>> 302 | __u32 btf_id;
>> | ^~~~~~
>>
>> Changing ASSERT_GE to ASSERT_EQ can fix the compilation error. Otherwise,
>> there is no functionality change.
>>
>> Error 3:
>> prog_tests/tailcalls.c: In function ‘test_tailcall_hierarchy_count’:
>> prog_tests/tailcalls.c:1402:23: error: ‘fentry_data_fd’ may be used uninitialized
>> in this function [-Werror=maybe-uninitialized]
>> 1402 | err = bpf_map_lookup_elem(fentry_data_fd, &i, &val);
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> The code is correct. The change intends to slient gcc errors.
> to silence.
>
> Fixed the typos while applying.
> Pls use spell check.
Sorry about typo's. Will pay attention to spell check for later patches.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-17 22:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-17 4:49 [PATCH bpf-next] selftests/bpf: Fix RELEASE build failure with gcc14 Yonghong Song
2025-06-17 17:24 ` Alexei Starovoitov
2025-06-17 22:09 ` Yonghong Song
2025-06-17 18:15 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).