summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@hadrons.org>2020-02-11 02:47:13 +0100
committerGuillem Jover <guillem@hadrons.org>2020-02-14 14:39:28 +0100
commita72c2db426c76696cafdb59704503fa504e6a7ff (patch)
tree4b1d4d083bfd20a54cdfc5ac3340bad50b8c26d7
parent9502d6d6465c58b812efe23da3a53fc34735e9b6 (diff)
downloadliburing-a72c2db426c76696cafdb59704503fa504e6a7ff.tar.gz
liburing-a72c2db426c76696cafdb59704503fa504e6a7ff.tar.bz2
test: Handle NULL sqe and cqe in tests
We need to check the return values from io_uring_queue_init() and recv_prep() or we will be passing a NULL sqe to io_uring_get_sqe(), or a NULL cge to io_uring_wait_cqe(). Signed-off-by: Guillem Jover <guillem@hadrons.org>
-rw-r--r--test/send_recv.c14
-rw-r--r--test/send_recvmsg.c15
2 files changed, 25 insertions, 4 deletions
diff --git a/test/send_recv.c b/test/send_recv.c
index 6a56744..000dad7 100644
--- a/test/send_recv.c
+++ b/test/send_recv.c
@@ -106,13 +106,23 @@ static void *recv_fn(void *data)
struct io_uring ring;
int ret;
- io_uring_queue_init(1, &ring, 0);
+ ret = io_uring_queue_init(1, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "queue init failed: %d\n", ret);
+ goto err;
+ }
- recv_prep(&ring, &iov);
+ ret = recv_prep(&ring, &iov);
+ if (ret) {
+ fprintf(stderr, "recv_prep failed: %d\n", ret);
+ goto err;
+ }
pthread_mutex_unlock(mutex);
ret = do_recv(&ring, &iov);
io_uring_queue_exit(&ring);
+
+err:
return (void *)(intptr_t)ret;
}
diff --git a/test/send_recvmsg.c b/test/send_recvmsg.c
index c4a8735..444d6a8 100644
--- a/test/send_recvmsg.c
+++ b/test/send_recvmsg.c
@@ -101,13 +101,24 @@ static void *recv_fn(void *data)
struct io_uring ring;
int ret;
- io_uring_queue_init(1, &ring, 0);
+ ret = io_uring_queue_init(1, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "queue init failed: %d\n", ret);
+ goto err;
+ }
+
+ ret = recv_prep(&ring, &iov);
+ if (ret) {
+ fprintf(stderr, "recv_prep failed: %d\n", ret);
+ goto err;
+ }
- recv_prep(&ring, &iov);
pthread_mutex_unlock(mutex);
ret = do_recvmsg(&ring, &iov);
io_uring_queue_exit(&ring);
+
+err:
return (void *)(intptr_t)ret;
}