Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

unix, windows: make uv_*_bind() error codes consistent

Just like uv_tcp_connect() it should return an EINVAL when the handle
is of an invalid type or when the network address is faulty.
  • Loading branch information...
commit 017e2d5fde0c22d959b0890abb4b614ebf7630f3 1 parent 372ac34
@txdv txdv authored bnoordhuis committed
View
8 src/uv-common.c
@@ -198,7 +198,7 @@ int uv_ip6_name(struct sockaddr_in6* src, char* dst, size_t size) {
int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
if (handle->type != UV_TCP || addr.sin_family != AF_INET) {
- uv__set_artificial_error(handle->loop, UV_EFAULT);
+ uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
@@ -208,7 +208,7 @@ int uv_tcp_bind(uv_tcp_t* handle, struct sockaddr_in addr) {
int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
if (handle->type != UV_TCP || addr.sin6_family != AF_INET6) {
- uv__set_artificial_error(handle->loop, UV_EFAULT);
+ uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
@@ -219,7 +219,7 @@ int uv_tcp_bind6(uv_tcp_t* handle, struct sockaddr_in6 addr) {
int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
unsigned int flags) {
if (handle->type != UV_UDP || addr.sin_family != AF_INET) {
- uv__set_artificial_error(handle->loop, UV_EFAULT);
+ uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
@@ -230,7 +230,7 @@ int uv_udp_bind(uv_udp_t* handle, struct sockaddr_in addr,
int uv_udp_bind6(uv_udp_t* handle, struct sockaddr_in6 addr,
unsigned int flags) {
if (handle->type != UV_UDP || addr.sin6_family != AF_INET6) {
- uv__set_artificial_error(handle->loop, UV_EFAULT);
+ uv__set_artificial_error(handle->loop, UV_EINVAL);
return -1;
}
View
2  test/test-tcp-bind-error.c
@@ -128,7 +128,7 @@ TEST_IMPL(tcp_bind_error_fault) {
r = uv_tcp_bind(&server, *garbage_addr);
ASSERT(r == -1);
- ASSERT(uv_last_error(uv_default_loop()).code == UV_EFAULT);
+ ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL);
uv_close((uv_handle_t*)&server, close_cb);
View
2  test/test-tcp-bind6-error.c
@@ -103,7 +103,7 @@ TEST_IMPL(tcp_bind6_error_fault) {
r = uv_tcp_bind6(&server, *garbage_addr);
ASSERT(r == -1);
- ASSERT(uv_last_error(uv_default_loop()).code == UV_EFAULT);
+ ASSERT(uv_last_error(uv_default_loop()).code == UV_EINVAL);
uv_close((uv_handle_t*)&server, close_cb);
Please sign in to comment.
Something went wrong with that request. Please try again.