diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-06-06 23:10:50 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-07-07 09:51:00 +0200 |
commit | 3ee4d3f183331a123ce35edd0d32268a2bb22aa5 (patch) | |
tree | e743fb6cee7f3a0d99d94cc0ad6e6e09dd270dd6 /test/test-tcp-connect-error-after-write.c | |
parent | 13f73fadff2388b5471f1dacbe72414b45baa48b (diff) | |
download | libuv-3ee4d3f183331a123ce35edd0d32268a2bb22aa5.tar.gz libuv-3ee4d3f183331a123ce35edd0d32268a2bb22aa5.zip |
unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.
A code snippet like this one:
if (uv_foo(loop) < 0) {
uv_err_t err = uv_last_error(loop);
fprintf(stderr, "%s\n", uv_strerror(err));
}
Should be rewritten like this:
int err = uv_foo(loop);
if (err < 0)
fprintf(stderr, "%s\n", uv_strerror(err));
The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
Diffstat (limited to 'test/test-tcp-connect-error-after-write.c')
-rw-r--r-- | test/test-tcp-connect-error-after-write.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/test/test-tcp-connect-error-after-write.c b/test/test-tcp-connect-error-after-write.c index e982c90a..4c8fdc2c 100644 --- a/test/test-tcp-connect-error-after-write.c +++ b/test/test-tcp-connect-error-after-write.c @@ -37,14 +37,14 @@ static void close_cb(uv_handle_t* handle) { static void connect_cb(uv_connect_t* req, int status) { - ASSERT(status == -1); + ASSERT(status < 0); connect_cb_called++; uv_close((uv_handle_t*)req->handle, close_cb); } static void write_cb(uv_write_t* req, int status) { - ASSERT(status == -1); + ASSERT(status < 0); write_cb_called++; } @@ -75,8 +75,7 @@ TEST_IMPL(tcp_connect_error_after_write) { ASSERT(r == 0); r = uv_write(&write_req, (uv_stream_t*)&conn, &buf, 1, write_cb); - ASSERT(r == -1); - ASSERT(uv_last_error(uv_default_loop()).code == UV_EBADF); + ASSERT(r == UV_EBADF); r = uv_tcp_connect(&connect_req, &conn, addr, connect_cb); ASSERT(r == 0); |