linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuntao Wang <ytcoode@gmail.com>
To: skhan@linuxfoundation.org
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
	daniel@iogearbox.net, hengqi.chen@gmail.com,
	john.fastabend@gmail.com, kafai@fb.com, kpsingh@kernel.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	netdev@vger.kernel.org, shuah@kernel.org, songliubraving@fb.com,
	yhs@fb.com, ytcoode@gmail.com
Subject: [PATCH bpf-next v2] selftests/bpf: Fix return value checks in perf_event_stackmap.c
Date: Fri,  8 Apr 2022 12:14:52 +0800	[thread overview]
Message-ID: <20220408041452.933944-1-ytcoode@gmail.com> (raw)
In-Reply-To: <7ac36fbe-aa44-9311-320b-1e953c29a3c4@linuxfoundation.org>

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@gmail.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


  reply	other threads:[~2022-04-08  4:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07 15:38 [PATCH bpf-next] selftests/bpf: Fix return value checks in perf_event_stackmap.c Yuntao Wang
2022-04-07 19:23 ` Shuah Khan
2022-04-08  4:14   ` Yuntao Wang [this message]
2022-04-08 21:09     ` [PATCH bpf-next v2] " patchwork-bot+netdevbpf

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=20220408041452.933944-1-ytcoode@gmail.com \
    --to=ytcoode@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hengqi.chen@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).