Skip to contentSkip to conversation

selftests: bpf: fix sockmap update nits

PATCH Applied Lorenz Bauer 3 participants 3 messages Aug 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: bpf: fix sockmap update nits

Address review by Yonghong, to bring the new tests in line with the usual code style.

---
 .../testing/selftests/bpf/prog_tests/sockmap_basic.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c +5 -7
index 65ce7c289534..0b79d78b98db 100644
@@ -118,10 +118,8 @@ static void test_sockmap_update(enum bpf_map_type map_type)
 		return;
 
 	skel = test_sockmap_update__open_and_load();
-	if (CHECK(!skel, "open_and_load", "cannot load skeleton\n")) {
-		close(sk);
-		return;
-	}
+	if (CHECK(!skel, "open_and_load", "cannot load skeleton\n"))
+		goto close_sk;
 
 	prog = bpf_program__fd(skel->progs.copy_sock_map);
 	src = bpf_map__fd(skel->maps.src);
@@ -158,8 +156,9 @@ static void test_sockmap_update(enum bpf_map_type map_type)
 	      dst_cookie, src_cookie);
 
 out:
-	close(sk);
 	test_sockmap_update__destroy(skel);
+close_sk:
+	close(sk);
 }
 
 static void test_sockmap_invalid_update(void)
@@ -168,8 +167,7 @@ static void test_sockmap_invalid_update(void)
 	int duration = 0;
 
 	skel = test_sockmap_invalid_update__open_and_load();
-	CHECK(skel, "open_and_load", "verifier accepted map_update\n");
-	if (skel)
+	if (CHECK(skel, "open_and_load", "verifier accepted map_update\n"))
 		test_sockmap_invalid_update__destroy(skel);
 }
 
Signature · 1 line
2.25.1