diff --git a/oio-unix.c b/oio-unix.c index 8c56a6cb8..4ac842438 100644 --- a/oio-unix.c +++ b/oio-unix.c @@ -69,12 +69,12 @@ static oio_err oio_err_new(oio_handle* handle, int e) { } -oio_err oio_err_last(oio_handle *handle) { +oio_err oio_err_last(oio_handle* handle) { return handle->err; } -struct sockaddr_in oio_ip4_addr(char *ip, int port) { +struct sockaddr_in oio_ip4_addr(char* ip, int port) { struct sockaddr_in addr; addr.sin_family = AF_INET; @@ -109,7 +109,7 @@ int oio_run() { } -int oio_tcp_init(oio_handle *handle, oio_close_cb close_cb, +int oio_tcp_init(oio_handle* handle, oio_close_cb close_cb, void* data) { handle->type = OIO_TCP; handle->close_cb = close_cb; @@ -472,7 +472,7 @@ void oio_tcp_connect(oio_handle* handle) { } -int oio_connect(oio_req *req, struct sockaddr* addr) { +int oio_connect(oio_req* req, struct sockaddr* addr) { oio_handle* handle = req->handle; if (handle->fd <= 0) { @@ -517,7 +517,7 @@ int oio_connect(oio_req *req, struct sockaddr* addr) { /* The buffers to be written must remain valid until the callback is called. */ /* This is not required for the oio_buf array. */ -int oio_write(oio_req *req, oio_buf* bufs, int bufcnt) { +int oio_write(oio_req* req, oio_buf* bufs, int bufcnt) { oio_handle* handle = req->handle; assert(handle->fd >= 0); ssize_t r; @@ -568,7 +568,7 @@ int64_t oio_now() { } -int oio_timeout(oio_req *req, int64_t timeout) { +int oio_timeout(oio_req* req, int64_t timeout) { ev_timer_init(&req->timer, oio__timeout, timeout / 1000.0, 0.0); ev_timer_start(EV_DEFAULT_UC_ &req->timer); req->timer.data = req; @@ -576,7 +576,7 @@ int oio_timeout(oio_req *req, int64_t timeout) { } -int oio_read(oio_req *req, oio_buf* bufs, int bufcnt) { +int oio_read(oio_req* req, oio_buf* bufs, int bufcnt) { oio_handle* handle = req->handle; ssize_t nread = -1; int errorno = EAGAIN; diff --git a/oio-win.c b/oio-win.c index 0bbdace09..f5670e050 100644 --- a/oio-win.c +++ b/oio-win.c @@ -65,7 +65,7 @@ typedef BOOL(*LPFN_CONNECTEX) (SOCKET s, - const struct sockaddr *name, + const struct sockaddr* name, int namelen, PVOID lpSendBuffer, DWORD dwSendDataLength, @@ -77,9 +77,9 @@ DWORD dwReceiveDataLength, DWORD dwLocalAddressLength, DWORD dwRemoteAddressLength, - LPSOCKADDR *LocalSockaddr, + LPSOCKADDR* LocalSockaddr, LPINT LocalSockaddrLength, - LPSOCKADDR *RemoteSockaddr, + LPSOCKADDR* RemoteSockaddr, LPINT RemoteSockaddrLength); typedef BOOL(*LPFN_DISCONNECTEX) @@ -190,9 +190,9 @@ static struct sockaddr_in oio_addr_ip4_any_; /* * Display an error message and abort the event loop. */ -static void oio_fatal_error(const int errorno, const char *syscall) { - char *buf = NULL; - const char *errmsg; +static void oio_fatal_error(const int errorno, const char* syscall) { + char* buf = NULL; + const char* errmsg; FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno, @@ -341,7 +341,7 @@ void oio_init() { } -void oio_req_init(oio_req* req, oio_handle* handle, void *cb) { +void oio_req_init(oio_req* req, oio_handle* handle, void* cb) { req->type = OIO_UNKNOWN_REQ; req->flags = 0; req->handle = handle; @@ -385,7 +385,7 @@ static int oio_set_socket_options(SOCKET socket) { } -int oio_tcp_init(oio_handle *handle, oio_close_cb close_cb, +int oio_tcp_init(oio_handle* handle, oio_close_cb close_cb, void* data) { handle->close_cb = close_cb; handle->data = data; @@ -481,7 +481,7 @@ int oio_close(oio_handle* handle) { static void oio_call_close_cbs() { - oio_handle *handle; + oio_handle* handle; while (oio_closed_handles_) { handle = oio_closed_handles_; @@ -505,7 +505,7 @@ static void oio_call_close_cbs() { } -struct sockaddr_in oio_ip4_addr(char *ip, int port) { +struct sockaddr_in oio_ip4_addr(char* ip, int port) { struct sockaddr_in addr; addr.sin_family = AF_INET; @@ -539,7 +539,7 @@ int oio_bind(oio_handle* handle, struct sockaddr* addr) { } -static void oio_queue_accept(oio_accept_req *areq, oio_handle *handle) { +static void oio_queue_accept(oio_accept_req* areq, oio_handle* handle) { BOOL success; DWORD bytes; @@ -666,7 +666,7 @@ int oio_connect(oio_req* req, struct sockaddr* addr) { } -int oio_write(oio_req *req, oio_buf* bufs, int bufcnt) { +int oio_write(oio_req* req, oio_buf* bufs, int bufcnt) { int result; DWORD bytes; oio_handle* handle = req->handle; @@ -695,7 +695,7 @@ int oio_write(oio_req *req, oio_buf* bufs, int bufcnt) { } -int oio_read(oio_req *req, oio_buf* bufs, int bufcnt) { +int oio_read(oio_req* req, oio_buf* bufs, int bufcnt) { int result; DWORD bytes, flags; oio_handle* handle = req->handle; @@ -725,7 +725,7 @@ int oio_read(oio_req *req, oio_buf* bufs, int bufcnt) { } -static int oio_timer_compare(oio_req *a, oio_req* b) { +static int oio_timer_compare(oio_req* a, oio_req* b) { if (a->due < b->due) return -1; if (a->due > b->due) @@ -779,7 +779,7 @@ static void oio_poll() { ULONG_PTR key; OVERLAPPED* overlapped; oio_req* req; - oio_accept_req *accept_req; + oio_accept_req* accept_req; oio_handle* handle; DWORD timeout; int64_t delta; diff --git a/oio.h b/oio.h index 0e4fa4ae7..577218bac 100644 --- a/oio.h +++ b/oio.h @@ -158,14 +158,14 @@ void oio_req_init(oio_req* req, oio_handle* handle, void* cb); /* * TODO: * - oio_(pipe|pipe_tty)_handle_init - * - oio_bind_pipe(char *name) - * - oio_continuous_read(oio_handle *handle, oio_continuous_read_cb *cb) + * - oio_bind_pipe(char* name) + * - oio_continuous_read(oio_handle* handle, oio_continuous_read_cb* cb) * - A way to list cancelled oio_reqs after before/on oio_close_cb */ /* TCP socket methods. */ /* Handle and callback bust be set by calling oio_req_init. */ -int oio_tcp_init(oio_handle *handle, oio_close_cb close_cb, void* data); +int oio_tcp_init(oio_handle* handle, oio_close_cb close_cb, void* data); int oio_bind(oio_handle* handle, struct sockaddr* addr); int oio_connect(oio_req* req, struct sockaddr* addr); int oio_shutdown(oio_req* req); @@ -184,7 +184,7 @@ int oio_read(oio_req* req, oio_buf* bufs, int bufcnt); int oio_write(oio_req* req, oio_buf* bufs, int bufcnt); /* Timer methods */ -int oio_timeout(oio_req *req, int64_t timeout); +int oio_timeout(oio_req* req, int64_t timeout); /* Request handle to be closed. close_cb will be called */ /* asynchronously after this call. */ diff --git a/test/run-tests.c b/test/run-tests.c index c46efd982..18a3727bb 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -33,7 +33,7 @@ #define TEST_TIMEOUT 20000 -static void log_progress(int total, int passed, int failed, char *name) { +static void log_progress(int total, int passed, int failed, char* name) { LOGF("[%% %3d|+ %3d|- %3d]: %-50s\n", (passed + failed) / total * 100, passed, failed, name); } @@ -41,7 +41,7 @@ static void log_progress(int total, int passed, int failed, char *name) { int main(int argc, char **argv) { int total, passed, failed; - task_entry_t *task; + task_entry_t* task; platform_init(); diff --git a/test/test-delayed-accept.c b/test/test-delayed-accept.c index 72e715304..5c538dd30 100644 --- a/test/test-delayed-accept.c +++ b/test/test-delayed-accept.c @@ -43,7 +43,7 @@ static void close_cb(oio_handle* handle, int status) { } -static void do_accept(oio_req *req, int status) { +static void do_accept(oio_req* req, int status) { oio_handle* server; oio_handle* accepted_handle = (oio_handle*)malloc(sizeof *accepted_handle); int r; @@ -102,7 +102,7 @@ static void start_server() { } -static void read_cb(oio_req *req, size_t nread, int status) { +static void read_cb(oio_req* req, size_t nread, int status) { /* The server will not send anything, it should close gracefully. */ ASSERT(req != NULL); ASSERT(status == 0); @@ -114,7 +114,7 @@ static void read_cb(oio_req *req, size_t nread, int status) { } -static void connect_cb(oio_req *req, int status) { +static void connect_cb(oio_req* req, int status) { oio_buf buf; int r; @@ -138,12 +138,10 @@ static void client_connect() { struct sockaddr_in addr = oio_ip4_addr("127.0.0.1", TEST_PORT); oio_handle* client = (oio_handle*)malloc(sizeof *client); oio_req* connect_req = (oio_req*)malloc(sizeof *connect_req); - oio_req* read_req = (oio_req*)malloc(sizeof *read_req); int r; ASSERT(client != NULL); ASSERT(connect_req != NULL); - ASSERT(read_req != NULL); r = oio_tcp_init(client, close_cb, NULL); ASSERT(r == 0);