public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing] test/probe: Use `io_uring_free_probe()` instead of `free()`
@ 2021-10-03  1:06 Ammar Faizi
  2021-10-03 13:06 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Ammar Faizi @ 2021-10-03  1:06 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring Mailing List, Ammar Faizi

`io_uring_free_probe()` should really be used to free the return value
of `io_uring_get_probe_ring()`. As we may not always allocate it with
`malloc()`. For example, to support no libc build [1].

Link: https://github.com/axboe/liburing/issues/443 [1]
Signed-off-by: Ammar Faizi <[email protected]>
---
 test/probe.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/test/probe.c b/test/probe.c
index 29239ff..fd59612 100644
--- a/test/probe.c
+++ b/test/probe.c
@@ -45,6 +45,7 @@ static int verify_probe(struct io_uring_probe *p, int full)
 
 static int test_probe_helper(struct io_uring *ring)
 {
+	int ret;
 	struct io_uring_probe *p;
 
 	p = io_uring_get_probe_ring(ring);
@@ -53,12 +54,9 @@ static int test_probe_helper(struct io_uring *ring)
 		return 1;
 	}
 
-	if (verify_probe(p, 1)) {
-		free(p);
-		return 1;
-	}
-
-	return 0;
+	ret = verify_probe(p, 1);
+	io_uring_free_probe(p);
+	return ret;
 }
 
 static int test_probe(struct io_uring *ring)
-- 
2.30.2


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

end of thread, other threads:[~2021-10-03 13:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-03  1:06 [PATCH liburing] test/probe: Use `io_uring_free_probe()` instead of `free()` Ammar Faizi
2021-10-03 13:06 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox