mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "longlong yan" <yanlonglong@kylinos.cn>, <andrii@kernel.org>,
	<eddyz87@gmail.com>, <ast@kernel.org>, <daniel@iogearbox.net>,
	<memxor@gmail.com>, <martin.lau@linux.dev>, <song@kernel.org>,
	<bpf@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] libarena: use ARRAY_SIZE macro in test_rbtree.bpf.c
Date: Fri, 17 Jul 2026 17:29:42 -0400	[thread overview]
Message-ID: <DK15ZPPHBWGS.12AEC4957Q8NL@etsalapatis.com> (raw)
In-Reply-To: <20260717073237.1048-1-yanlonglong@kylinos.cn>

On Fri Jul 17, 2026 at 3:32 AM EDT, longlong yan wrote:
> 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>

NACK, please see the exact same comment I made on the other thread
that made the same change for the ASAN buddy selftests.

pw-bot: cr

> ---
>  .../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;


  parent reply	other threads:[~2026-07-17 21:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  7:32 longlong yan
2026-07-17  8:29 ` bot+bpf-ci
2026-07-17 21:29 ` Emil Tsalapatis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-07-17  6:47 longlong yan

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=DK15ZPPHBWGS.12AEC4957Q8NL@etsalapatis.com \
    --to=emil@etsalapatis.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=yanlonglong@kylinos.cn \
    /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