It seemed incorrect to map a segfault to EACCES, since posix would typically
map this to EFAULT. The ERROR_BUFFER_OVERFLOW is literally "the filename is too
long", and is not typically an invalid parameter in posix.
Test originally added in #1060 to test the API, not the value.
Switch from old-style ASSERT macro to new-style ASSERT_EQ,... macros.
Using new-style macros makes it easier to debug test failures
Fixes: https://github.com/libuv/libuv/issues/2974
Moving to new style test macros will make debugging easier in case
of test failure and improve redability. This commit will replace all
ASSERT macros matching the statement:
`ASSERT(identifier (== or !=) value);`
to:
`ASSERT_(NOT_)NULL(identifier);`
Refs: https://github.com/libuv/libuv/issues/2974
PR-URL: https://github.com/libuv/libuv/pull/3081
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This PR creates two new externally-facing APIs, uv_err_name_r() and
uv_strerror_r().
In keeping with the precedent set by POSIX, the *_r() suffix of these
two new methods indicate that the caller does the memory management and
passes in the memory that the output will be stored in, which provides
an alternative for the two existent methods (uv_err_name() and
uv_strerror()), which, when called with an unknown error code, leak a
few bytes of memory.
PR-URL: https://github.com/libuv/libuv/pull/1898
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno santiago.gimeno@gmail.com
uv_spawn() on Windows will fail with ERROR_ELEVATION_REQUIRED
if attempting to run an application that requires elevation.
Fixes: https://github.com/nodejs/node/issues/9464
PR-URL: https://github.com/libuv/libuv/pull/1154
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
uv_translate_sys_error() was a private function for Windows.
This commit adds an equivalent function on other platforms, and
exposes it as public API.
Exposing this is useful in scenarios where the application uses
both libuv functions and platform-specific system calls and wants
to report errors uniformly as libuv errors.
Fixes: https://github.com/libuv/libuv/issues/79
PR-URL: https://github.com/libuv/libuv/pull/1060
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
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.