[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220408041452.933944-1-ytcoode@gmail.com>
Date: Fri, 8 Apr 2022 12:14:52 +0800
From: Yuntao Wang <ytcoode@...il.com>
To: skhan@...uxfoundation.org
Cc: andrii@...nel.org, ast@...nel.org, bpf@...r.kernel.org,
daniel@...earbox.net, hengqi.chen@...il.com,
john.fastabend@...il.com, kafai@...com, kpsingh@...nel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
netdev@...r.kernel.org, shuah@...nel.org, songliubraving@...com,
yhs@...com, ytcoode@...il.com
Subject: [PATCH bpf-next v2] selftests/bpf: Fix return value checks in perf_event_stackmap.c
The bpf_get_stackid() function may also return 0 on success.
Correct checks from 'val > 0' to 'val >= 0' to ensure that they cover all
possible success return values.
Signed-off-by: Yuntao Wang <ytcoode@...il.com>
---
v1 -> v2: update commit message
tools/testing/selftests/bpf/progs/perf_event_stackmap.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c
index b3fcb5274ee0..f793280a3238 100644
--- a/tools/testing/selftests/bpf/progs/perf_event_stackmap.c
+++ b/tools/testing/selftests/bpf/progs/perf_event_stackmap.c
@@ -35,10 +35,10 @@ int oncpu(void *ctx)
long val;
val = bpf_get_stackid(ctx, &stackmap, 0);
- if (val > 0)
+ if (val >= 0)
stackid_kernel = 2;
val = bpf_get_stackid(ctx, &stackmap, BPF_F_USER_STACK);
- if (val > 0)
+ if (val >= 0)
stackid_user = 2;
trace = bpf_map_lookup_elem(&stackdata_map, &key);
--
2.35.0.rc2
Powered by blists - more mailing lists