diff mbox series

[bpf-next,2/8] selftests/bpf: Drop duplicate definition of i in test_sockmap

Message ID 8d690682330a59361562bca75d6903253d16f312.1716446893.git.tanggeliang@kylinos.cn
State New
Headers show
Series fixes for test_sockmap | expand

Commit Message

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

There's already a definition of i in run_options() at the beginning, no
need to define a new one in "if (tx_prog_fd > 0)" block.

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

Comments

John Fastabend May 27, 2024, 5:03 p.m. UTC | #1
Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> There's already a definition of i in run_options() at the beginning, no
> need to define a new one in "if (tx_prog_fd > 0)" block.
> 
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---

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 fde0dd741e69..e7dbf49a2ca6 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -1030,7 +1030,7 @@  static int run_options(struct sockmap_options *options, int cg_fd,  int test)
 		tx_prog_fd = -1;
 
 	if (tx_prog_fd > 0) {
-		int redir_fd, i = 0;
+		int redir_fd;
 
 		err = bpf_prog_attach(tx_prog_fd,
 				      map_fd[1], BPF_SK_MSG_VERDICT, 0);
@@ -1041,6 +1041,7 @@  static int run_options(struct sockmap_options *options, int cg_fd,  int test)
 			goto out;
 		}
 
+		i = 0;
 		err = bpf_map_update_elem(map_fd[1], &i, &c1, BPF_ANY);
 		if (err) {
 			fprintf(stderr,