summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-11-28 08:13:52 -0700
committerJens Axboe <axboe@kernel.dk>2019-11-28 08:13:52 -0700
commit5943354615a2e419aa203e466695499d4c68aecb (patch)
treeaad956e337ef0d85a946af26d4ea4c49b13d1402
parent6e3f6f3a35140a7dbb06bc63906948e17a77c227 (diff)
downloadliburing-5943354615a2e419aa203e466695499d4c68aecb.tar.gz
liburing-5943354615a2e419aa203e466695499d4c68aecb.tar.bz2
test/connect: fixup a few style issues
Also, the liburing helpers return -errno, not -1/errno. The usage of io_uring_submit_and_wait() was wrong, fix it. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/connect.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/test/connect.c b/test/connect.c
index ea9334d..7c88e27 100644
--- a/test/connect.c
+++ b/test/connect.c
@@ -16,7 +16,7 @@
#include "liburing.h"
-int create_socket()
+static int create_socket(void)
{
int fd;
@@ -29,32 +29,31 @@ int create_socket()
return fd;
}
-int submit_and_wait(struct io_uring* ring, int* res)
+static int submit_and_wait(struct io_uring *ring, int *res)
{
- struct io_uring_cqe* cqe;
+ struct io_uring_cqe *cqe;
int ret;
ret = io_uring_submit_and_wait(ring, 1);
- if (ret == -1) {
- perror("io_uring_submit()");
- return -1;
+ if (ret != 1) {
+ fprintf(stderr, "io_using_submit: got %d\n", ret);
+ return 1;
}
ret = io_uring_peek_cqe(ring, &cqe);
if (ret == -1) {
fprintf(stderr, "io_uring_peek_cqe(): no cqe returned");
- return -1;
+ return 1;
}
*res = cqe->res;
io_uring_cqe_seen(ring, cqe);
-
return 0;
}
-int wait_for(struct io_uring* ring, int fd, int mask)
+static int wait_for(struct io_uring *ring, int fd, int mask)
{
- struct io_uring_sqe* sqe;
+ struct io_uring_sqe *sqe;
int ret, res;
sqe = io_uring_get_sqe(ring);
@@ -67,7 +66,7 @@ int wait_for(struct io_uring* ring, int fd, int mask)
sqe->user_data = 2;
ret = submit_and_wait(ring, &res);
- if (ret == -1)
+ if (ret)
return -1;
if (res < 0) {
@@ -78,7 +77,7 @@ int wait_for(struct io_uring* ring, int fd, int mask)
return res;
}
-int listen_on_socket(int fd)
+static int listen_on_socket(int fd)
{
struct sockaddr_in addr;
int ret;
@@ -103,9 +102,9 @@ int listen_on_socket(int fd)
return 0;
}
-int connect_socket(struct io_uring* ring, int fd, int* code)
+static int connect_socket(struct io_uring *ring, int fd, int *code)
{
- struct io_uring_sqe* sqe;
+ struct io_uring_sqe *sqe;
struct sockaddr_in addr;
int ret, res, val = 1;
socklen_t code_len = sizeof(*code);
@@ -137,7 +136,7 @@ int connect_socket(struct io_uring* ring, int fd, int* code)
sqe->user_data = 1;
ret = submit_and_wait(ring, &res);
- if (ret == -1)
+ if (ret)
return -1;
if (res != -EINPROGRESS) {
@@ -164,7 +163,7 @@ int connect_socket(struct io_uring* ring, int fd, int* code)
return 0;
}
-int test_connect_with_no_peer(struct io_uring* ring)
+static int test_connect_with_no_peer(struct io_uring *ring)
{
int connect_fd;
int ret, code;
@@ -190,7 +189,7 @@ err:
return -1;
}
-int test_connect(struct io_uring* ring)
+static int test_connect(struct io_uring *ring)
{
int accept_fd;
int connect_fd;
@@ -230,7 +229,7 @@ err1:
return -1;
}
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
struct io_uring ring;
int ret;