Skip to content

Commit c810b31

Browse files
jrfastabAlexei Starovoitov
authored and
Alexei Starovoitov
committed
bpf, selftests: Fix warning in snprintf_btf where system() call unchecked
On my systems system() calls are marked with warn_unused_result apparently. So without error checking we get this warning, ./prog_tests/snprintf_btf.c:30:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result[-Wunused-result] Also it seems like a good idea to check the return value anyways to ensure ping exists even if its seems unlikely. Fixes: 076a95f ("selftests/bpf: Add bpf_snprintf_btf helper tests") Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/160141006897.25201.12095049414156293265.stgit@john-Precision-5820-Tower
1 parent 93b8713 commit c810b31

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/testing/selftests/bpf/prog_tests/snprintf_btf.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ void test_snprintf_btf(void)
2727
goto cleanup;
2828

2929
/* generate receive event */
30-
(void) system("ping -c 1 127.0.0.1 > /dev/null");
30+
err = system("ping -c 1 127.0.0.1 > /dev/null");
31+
if (CHECK(err, "system", "ping failed: %d\n", err))
32+
goto cleanup;
3133

3234
if (bss->skip) {
3335
printf("%s:SKIP:no __builtin_btf_type_id\n", __func__);

0 commit comments

Comments
 (0)