oio_err -> oio_err_t

This commit is contained in:
Ryan Dahl 2011-05-09 02:30:11 -07:00
parent f71ea7f65d
commit 8f9ff78413
6 changed files with 23 additions and 23 deletions

View File

@ -34,7 +34,7 @@
#include <arpa/inet.h>
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;

View File

@ -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;
}

View File

@ -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 }; \

6
oio.h
View File

@ -28,7 +28,7 @@
#include <stdint.h> /* int64_t */
#include <sys/types.h> /* 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);

View File

@ -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);
}

View File

@ -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);
}