From: sashiko-bot@kernel.org
To: luoliang@kylinos.cn
Cc: bpf@vger.kernel.org, sched-ext@lists.linux.dev
Subject: Re: [PATCH] tools/sched_ext: use btf_vlen() helper in compat.h
Date: Tue, 30 Jun 2026 03:20:27 +0000 [thread overview]
Message-ID: <20260630032027.92BB51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630031246.2618216-1-luoliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The patch fails to resolve the `-Wsign-compare` warning it claims to fix because `btf_vlen()` returns `__u32`, not `__u16`.
--
commit 4880227aa1b0e483fd0500c9f49fa0639cd32d8b
Author: luoliang <luoliang@kylinos.cn>
tools/sched_ext: use btf_vlen() helper in compat.h
This commit replaces open-coded BTF_INFO_VLEN() lookups with btf_vlen() in
compat.h, intending to fix a -Wsign-compare compiler warning.
> libbpf already exposes btf_vlen() for exactly this purpose; it
> returns __u16, the natural width of the vlen field, and the usual
> integer promotions turn the 'int < __u16' comparison into a plain
> 'int < int' so the warning goes away without any cast. This matches
[Severity: Medium]
Is this description accurate?
Looking at the definitions in include/linux/btf.h and tools/lib/bpf/btf.h,
btf_vlen() is defined to return an unsigned 32-bit integer (u32 or __u32),
not a __u16:
static inline u32 btf_vlen(const struct btf_type *t)
{
return btf_type_vlen(t);
}
Because it returns an unsigned 32-bit integer, won't comparing it against
a signed int still trigger the -Wsign-compare warning?
> diff --git a/tools/sched_ext/include/scx/compat.h b/tools/sched_ext/include/scx/compat.h
> index 602f07061ee39..5b92e9c85d03d 100644
> --- a/tools/sched_ext/include/scx/compat.h
> +++ b/tools/sched_ext/include/scx/compat.h
> @@ -42,7 +42,7 @@ static inline bool __COMPAT_read_enum(const char *type, const char *name, u64 *v
> if (btf_is_enum(t)) {
> struct btf_enum *e = btf_enum(t);
>
> - for (i = 0; i < BTF_INFO_VLEN(t->info); i++) {
> + for (i = 0; i < btf_vlen(t); i++) {
[Severity: Medium]
Does this code still compare a signed int 'i' against the unsigned 32-bit
return value of btf_vlen(t)?
Other places in the kernel (like kernel/bpf/inode.c) and bpftool typically
avoid this warning by either declaring their loop counter as a __u32, or by
explicitly assigning the result of btf_vlen() to an int variable before the
loop. Should one of those approaches be used here instead?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630031246.2618216-1-luoliang@kylinos.cn?part=1
next prev parent reply other threads:[~2026-06-30 3:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 3:12 [PATCH] tools/sched_ext: use btf_vlen() helper in compat.h luoliang
2026-06-30 3:20 ` sashiko-bot [this message]
2026-06-30 5:13 ` Andrea Righi
2026-06-30 8:15 ` luoliang
2026-06-30 8:17 ` [PATCH v2] " luoliang
2026-06-30 8:27 ` Andrea Righi
2026-06-30 14:24 ` Tejun Heo
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=20260630032027.92BB51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=luoliang@kylinos.cn \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
/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