diff mbox series

[bpf-next,6/8] selftests/bpf: Fix size of map_fd in test_sockmap

Message ID 0972529ee01ebf8a8fd2b310bdec90831c94be77.1716446893.git.tanggeliang@kylinos.cn (mailing list archive)
State New
Headers show
Series fixes for test_sockmap | expand

Commit Message

Geliang Tang May 23, 2024, 6:50 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

The array size of map_fd[] is 9, not 8. This patch changes it as a more
general form: ARRAY_SIZE(map_fd).

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/bpf/test_sockmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Fastabend May 27, 2024, 5:06 p.m. UTC | #1
Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The array size of map_fd[] is 9, not 8. This patch changes it as a more
> general form: ARRAY_SIZE(map_fd).
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  tools/testing/selftests/bpf/test_sockmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
> index e83ca0005721..3654babfac59 100644
> --- a/tools/testing/selftests/bpf/test_sockmap.c
> +++ b/tools/testing/selftests/bpf/test_sockmap.c
> @@ -1285,7 +1285,7 @@ static int run_options(struct sockmap_options *options, int cg_fd,  int test)
>  			bpf_link__detach(links[i]);
>  	}
>  
> -	for (i = 0; i < 8; i++) {
> +	for (i = 0; i < ARRAY_SIZE(map_fd); i++) {
>  		key = next_key = 0;
>  		bpf_map_update_elem(map_fd[i], &key, &zero, BPF_ANY);
>  		while (bpf_map_get_next_key(map_fd[i], &key, &next_key) == 0) {
> -- 
> 2.43.0
> 

Acked-by: John Fastabend <john.fastabend@gmail.com>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index e83ca0005721..3654babfac59 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -1285,7 +1285,7 @@  static int run_options(struct sockmap_options *options, int cg_fd,  int test)
 			bpf_link__detach(links[i]);
 	}
 
-	for (i = 0; i < 8; i++) {
+	for (i = 0; i < ARRAY_SIZE(map_fd); i++) {
 		key = next_key = 0;
 		bpf_map_update_elem(map_fd[i], &key, &zero, BPF_ANY);
 		while (bpf_map_get_next_key(map_fd[i], &key, &next_key) == 0) {