All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c
@ 2026-07-17  6:47 longlong yan
  2026-07-17  6:57 ` sashiko-bot
  0 siblings, 1 reply; 4+ messages in thread
From: longlong yan @ 2026-07-17  6:47 UTC (permalink / raw)
  To: andrii, eddyz87, ast, daniel, memxor, martin.lau, song, bpf,
	linux-kselftest, linux-kernel
  Cc: longlong yan

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

Fixes: 6c3e8a4d4765 ("selftests/bpf: libarena: Add rbtree data structure")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
 .../selftests/bpf/libarena/selftests/test_rbtree.bpf.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
index 856c484a009a..f6e15f77cdf5 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
@@ -275,7 +275,7 @@ clean_up_noalloc_tree(struct rbtree __arena *rbtree)
 
 int insert_many(enum rbtree_alloc alloc, enum rbtree_insert_mode insert)
 {
-	const size_t numkeys = sizeof(keys) / sizeof(keys[0]);
+	const size_t numkeys = ARRAY_SIZE(keys);
 	node_ctx nodec;
 	u64 key, value;
 	int ret;
@@ -373,7 +373,7 @@ __weak int test_rbtree_remove_one(void)
 
 static __always_inline int remove_many_verify_all_present(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	u64 value;
 	int ret;
 	int i;
@@ -394,7 +394,7 @@ static __always_inline int remove_many_verify_all_present(struct rbtree __arena
 
 static __always_inline int remove_many_verify_remaining(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	u64 value;
 	int ret;
 	int i;
@@ -434,7 +434,7 @@ static __always_inline int remove_many_verify_remaining(struct rbtree __arena *r
 
 static __noinline int remove_many_alloc(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	u64 value;
 	int ret;
 	int i;
@@ -482,7 +482,7 @@ static __noinline int remove_many_alloc(struct rbtree __arena *rbtree)
 
 static __noinline int remove_many_noalloc(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	node_ctx first = NULL, last = NULL;
 	u64 value;
 	int ret;
-- 
2.43.0


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

* Re: [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c
  2026-07-17  6:47 [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c longlong yan
@ 2026-07-17  6:57 ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-07-17  6:57 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 `ARRAY_SIZE` macro is used but never defined, resulting in a build failure.
--

--- Patch [1]: [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c ---
commit 49bb37468e341cf82c49ff84b927aa30773d6092
Author: longlong yan <yanlonglong@kylinos.cn>

libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c

This commit replaces manual array size calculations with the ARRAY_SIZE
macro throughout the test_rbtree.bpf.c selftest.

> diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
> index 856c484a009a8..f6e15f77cdf5a 100644
> --- a/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
> +++ b/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
> @@ -275,7 +275,7 @@ clean_up_noalloc_tree(struct rbtree __arena *rbtree)
>  
>  int insert_many(enum rbtree_alloc alloc, enum rbtree_insert_mode insert)
>  {
> -	const size_t numkeys = sizeof(keys) / sizeof(keys[0]);
> +	const size_t numkeys = ARRAY_SIZE(keys);

[Severity: Low]
Does this code fail to build because ARRAY_SIZE is not defined?

It appears ARRAY_SIZE is not provided by the headers included in this 
translation unit, which could cause the compiler to reject it as an
undeclared identifier during the selftest compilation.

[ ... ]

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

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

* [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c
@ 2026-07-17  7:32 longlong yan
  2026-07-17  8:29 ` bot+bpf-ci
  0 siblings, 1 reply; 4+ messages in thread
From: longlong yan @ 2026-07-17  7:32 UTC (permalink / raw)
  To: andrii, eddyz87, ast, daniel, memxor, martin.lau, song, bpf,
	linux-kselftest, linux-kernel
  Cc: longlong yan

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

Fixes: 6c3e8a4d4765 ("selftests/bpf: libarena: Add rbtree data structure")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
---
 .../bpf/libarena/selftests/test_rbtree.bpf.c        | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
index 856c484a009a..2b4f519d6c4b 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_rbtree.bpf.c
@@ -4,6 +4,9 @@
 
 #include <libarena/asan.h>
 #include <libarena/rbtree.h>
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+#endif
 
 typedef struct node_ctx __arena *node_ctx;
 
@@ -275,7 +278,7 @@ clean_up_noalloc_tree(struct rbtree __arena *rbtree)
 
 int insert_many(enum rbtree_alloc alloc, enum rbtree_insert_mode insert)
 {
-	const size_t numkeys = sizeof(keys) / sizeof(keys[0]);
+	const size_t numkeys = ARRAY_SIZE(keys);
 	node_ctx nodec;
 	u64 key, value;
 	int ret;
@@ -373,7 +376,7 @@ __weak int test_rbtree_remove_one(void)
 
 static __always_inline int remove_many_verify_all_present(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	u64 value;
 	int ret;
 	int i;
@@ -394,7 +397,7 @@ static __always_inline int remove_many_verify_all_present(struct rbtree __arena
 
 static __always_inline int remove_many_verify_remaining(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	u64 value;
 	int ret;
 	int i;
@@ -434,7 +437,7 @@ static __always_inline int remove_many_verify_remaining(struct rbtree __arena *r
 
 static __noinline int remove_many_alloc(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	u64 value;
 	int ret;
 	int i;
@@ -482,7 +485,7 @@ static __noinline int remove_many_alloc(struct rbtree __arena *rbtree)
 
 static __noinline int remove_many_noalloc(struct rbtree __arena *rbtree)
 {
-	const size_t numkeys = sizeof(morekeys) / sizeof(morekeys[0]);
+	const size_t numkeys = ARRAY_SIZE(morekeys);
 	node_ctx first = NULL, last = NULL;
 	u64 value;
 	int ret;
-- 
2.43.0


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

* Re: [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c
  2026-07-17  7:32 longlong yan
@ 2026-07-17  8:29 ` bot+bpf-ci
  0 siblings, 0 replies; 4+ messages in thread
From: bot+bpf-ci @ 2026-07-17  8:29 UTC (permalink / raw)
  To: yanlonglong, andrii, eddyz87, ast, daniel, memxor, martin.lau,
	song, bpf, linux-kselftest, linux-kernel
  Cc: yanlonglong, ast, andrii, daniel, martin.lau, eddyz87,
	yonghong.song, clm, ihor.solodrai

[-- Attachment #1: Type: text/plain, Size: 888 bytes --]

>     libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c
>
>     The ARRAY_SIZE macro is more compact and more formal in linux source.
>
>     Fixes: 6c3e8a4d4765 ("selftests/bpf: libarena: Add rbtree data structure")
>     Signed-off-by: longlong yan <yanlonglong@kylinos.cn>

Should this commit include a Fixes: tag? The original code in commit
6c3e8a4d4765 was functionally correct - 'sizeof(keys) / sizeof(keys[0])'
produces the same result as 'ARRAY_SIZE(keys)'. This change improves code
style and readability but doesn't fix a bug.

Fixes: tags are typically reserved for commits that correct incorrect
behavior or address actual defects.


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/29564321134

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

end of thread, other threads:[~2026-07-17  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-17  6:47 [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c longlong yan
2026-07-17  6:57 ` sashiko-bot
  -- strict thread matches above, loose matches on Subject: below --
2026-07-17  7:32 longlong yan
2026-07-17  8:29 ` bot+bpf-ci

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.