diff --git a/oio-unix.c b/oio-unix.c index 3f903750..aa59a9cc 100644 --- a/oio-unix.c +++ b/oio-unix.c @@ -34,7 +34,7 @@ #include -static oio_err last_err; +static oio_err_t last_err; static oio_alloc_cb alloc_cb; @@ -60,12 +60,12 @@ void oio_flag_set(oio_handle_t* handle, int flag) { } -oio_err oio_last_error() { +oio_err_t oio_last_error() { return last_err; } -char* oio_strerror(oio_err err) { +char* oio_strerror(oio_err_t err) { return strerror(err.sys_errno_); } @@ -97,8 +97,8 @@ static oio_err_code oio_translate_sys_error(int sys_errno) { } -static oio_err oio_err_new_artificial(oio_handle_t* handle, int code) { - oio_err err; +static oio_err_t oio_err_new_artificial(oio_handle_t* handle, int code) { + oio_err_t err; err.sys_errno_ = 0; err.code = code; last_err = err; @@ -106,8 +106,8 @@ static oio_err oio_err_new_artificial(oio_handle_t* handle, int code) { } -static oio_err oio_err_new(oio_handle_t* handle, int sys_error) { - oio_err err; +static oio_err_t oio_err_new(oio_handle_t* handle, int sys_error) { + oio_err_t err; err.sys_errno_ = sys_error; err.code = oio_translate_sys_error(sys_error); last_err = err; @@ -526,7 +526,7 @@ void oio__write(oio_handle_t* handle) { if (n < 0) { if (errno != EAGAIN) { - oio_err err = oio_err_new(handle, errno); + oio_err_t err = oio_err_new(handle, errno); /* XXX How do we handle the error? Need test coverage here. */ oio_close(handle); @@ -725,7 +725,7 @@ static void oio_tcp_connect(oio_handle_t* handle) { return; } else { - oio_err err = oio_err_new(handle, error); + oio_err_t err = oio_err_new(handle, error); handle->connect_req = NULL; diff --git a/oio-win.c b/oio-win.c index f1cc8b44..3239dbc2 100644 --- a/oio-win.c +++ b/oio-win.c @@ -176,8 +176,8 @@ static HANDLE oio_iocp_; /* Global error code */ -static const oio_err oio_ok_ = { OIO_OK, ERROR_SUCCESS }; -static oio_err oio_last_error_ = { OIO_OK, ERROR_SUCCESS }; +static const oio_err_t oio_ok_ = { OIO_OK, ERROR_SUCCESS }; +static oio_err_t oio_last_error_ = { OIO_OK, ERROR_SUCCESS }; /* Error message string */ static char* oio_err_str_ = NULL; @@ -258,12 +258,12 @@ static void oio_fatal_error(const int errorno, const char* syscall) { } -oio_err oio_last_error() { +oio_err_t oio_last_error() { return oio_last_error_; } -char* oio_strerror(oio_err err) { +char* oio_strerror(oio_err_t err) { if (oio_err_str_ != NULL) { LocalFree((void*) oio_err_str_); } @@ -302,8 +302,8 @@ static oio_err_code oio_translate_sys_error(int sys_errno) { } -static oio_err oio_new_sys_error(int sys_errno) { - oio_err e; +static oio_err_t oio_new_sys_error(int sys_errno) { + oio_err_t e; e.code = oio_translate_sys_error(sys_errno); e.sys_errno_ = sys_errno; return e; @@ -486,7 +486,7 @@ int oio_tcp_init(oio_handle_t* handle, oio_close_cb close_cb, static void oio_tcp_endgame(oio_handle_t* handle) { - oio_err err; + oio_err_t err; int status; if (handle->flags & OIO_HANDLE_SHUTTING && @@ -605,7 +605,7 @@ static void oio_want_endgame(oio_handle_t* handle) { } -static int oio_close_error(oio_handle_t* handle, oio_err e) { +static int oio_close_error(oio_handle_t* handle, oio_err_t e) { if (handle->flags & OIO_HANDLE_CLOSING) { return 0; } diff --git a/oio-win.h b/oio-win.h index e699f33b..ff9e0619 100644 --- a/oio-win.h +++ b/oio-win.h @@ -89,7 +89,7 @@ typedef struct oio_buf { #define oio_handle_private_fields \ oio_handle_t* endgame_next; \ unsigned int flags; \ - oio_err error; \ + oio_err_t error; \ union { \ struct { oio_tcp_fields }; \ struct { oio_loop_fields }; \ diff --git a/oio.h b/oio.h index 43a3644d..dc790240 100644 --- a/oio.h +++ b/oio.h @@ -28,7 +28,7 @@ #include /* int64_t */ #include /* size_t */ -typedef struct oio_err_s oio_err; +typedef struct oio_err_s oio_err_t; typedef struct oio_handle_s oio_handle_t; typedef struct oio_req_s oio_req_t; @@ -159,8 +159,8 @@ struct oio_handle_s { * On error the user should then call oio_last_error() to determine * the error code. */ -oio_err oio_last_error(); -char* oio_strerror(oio_err err); +oio_err_t oio_last_error(); +char* oio_strerror(oio_err_t err); void oio_init(oio_alloc_cb alloc); diff --git a/test/echo-server.c b/test/echo-server.c index bc8d5781..38cfe95c 100644 --- a/test/echo-server.c +++ b/test/echo-server.c @@ -44,7 +44,7 @@ static void after_write(oio_req_t* req, int status) { write_req_t* wr; if (status) { - oio_err err = oio_last_error(); + oio_err_t err = oio_last_error(); fprintf(stderr, "oio_write error: %s\n", oio_strerror(err)); ASSERT(0); } diff --git a/test/test-tcp-writealot.c b/test/test-tcp-writealot.c index c5ad8045..0827b076 100644 --- a/test/test-tcp-writealot.c +++ b/test/test-tcp-writealot.c @@ -94,7 +94,7 @@ static void write_cb(oio_req_t* req, int status) { ASSERT(req != NULL); if (status) { - oio_err err = oio_last_error(); + oio_err_t err = oio_last_error(); fprintf(stderr, "oio_write error: %s\n", oio_strerror(err)); ASSERT(0); }