BPF List
 help / color / mirror / Atom feed
* [PATCH] libarena/selftests: use ARRAY_SIZE macro in st_asan_buddy.bpf.c
@ 2026-07-16  7:11 longlong yan
  2026-07-16  7:23 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: longlong yan @ 2026-07-16  7:11 UTC (permalink / raw)
  To: bpf, linux-kselftest, linux-kernel, andrii, daniel, martin.lau
  Cc: longlong yan

The ARRAY_SIZE macro is more compact and more formal in linux source.

Fixes: b1487dc1b181 ("selftests/bpf: Add selftests for libarena buddy allocator")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
 .../selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c
index 3266a28f53d7..9c94a5167a50 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c
@@ -163,7 +163,7 @@ __weak int asan_test_buddy_oob(void)
 		return ret;
 	}
 
-	for (i = zero; i < sizeof(sizes) / sizeof(sizes[0]) && can_loop; i++) {
+	for (i = zero; i < ARRAY_SIZE(sizes) && can_loop; i++) {
 		barrier_var(i);
 		ret = asan_test_buddy_oob_single(sizes[i]);
 		if (ret) {
@@ -201,7 +201,7 @@ __weak int asan_test_buddy_uaf(void)
 		return ret;
 	}
 
-	for (i = zero; i < sizeof(sizes) / sizeof(sizes[0]) && can_loop; i++) {
+	for (i = zero; i < ARRAY_SIZE(sizes) && can_loop; i++) {
 		barrier_var(i);
 		ret = asan_test_buddy_uaf_single(sizes[i]);
 		if (ret) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libarena/selftests: use ARRAY_SIZE macro in st_asan_buddy.bpf.c
  2026-07-16  7:11 [PATCH] libarena/selftests: use ARRAY_SIZE macro in st_asan_buddy.bpf.c longlong yan
@ 2026-07-16  7:23 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-16  7:23 UTC (permalink / raw)
  To: longlong yan; +Cc: bpf

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The commit introduces the `ARRAY_SIZE` macro into a BPF program without defining or including it, causing a compilation failure.
--

--- Patch [1]: [PATCH] libarena/selftests: use ARRAY_SIZE macro in st_asan_buddy.bpf.c ---
commit 70521e8b40248839f7100def222aa4fb06724c32
Author: longlong yan <yanlonglong@kylinos.cn>
libarena/selftests: use ARRAY_SIZE macro in st_asan_buddy.bpf.c

This commit replaces manual array size calculations with the ARRAY_SIZE macro 
in the asan_test_buddy_oob and asan_test_buddy_uaf functions to make the code 
more compact.

> diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c
> index 3266a28f53d76..9c94a5167a503 100644
> --- a/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c
> +++ b/tools/testing/selftests/bpf/libarena/selftests/test_asan_buddy.bpf.c
> @@ -163,7 +163,7 @@ __weak int asan_test_buddy_oob(void)
>  		return ret;
>  	}
>  
> -	for (i = zero; i < sizeof(sizes) / sizeof(sizes[0]) && can_loop; i++) {
> +	for (i = zero; i < ARRAY_SIZE(sizes) && can_loop; i++) {

[Severity: Low]
Does this cause a compilation failure when building the BPF selftests?

It appears that ARRAY_SIZE is not defined in this BPF program or its currently
included headers. Would we need to define ARRAY_SIZE locally in this file, or
include a header that provides it specifically for BPF environments?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260716071110.560-1-yanlonglong@kylinos.cn?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-16  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  7:11 [PATCH] libarena/selftests: use ARRAY_SIZE macro in st_asan_buddy.bpf.c longlong yan
2026-07-16  7:23 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox