unix: fix clang scan-build warning

When building libuv with clang scan-build, an "Assigned value is
garbage or undefined" warning is emitted unless the return value
of open() is verified to be >= 0. This commit fixes the warning.

PR-URL: https://github.com/libuv/libuv/pull/2140
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Kyle Edwards 2019-01-11 15:59:51 -05:00 committed by cjihrig
parent a833f921b8
commit 69c85fa88e
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -315,7 +315,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
use_fd = open("/dev/null", fd == 0 ? O_RDONLY : O_RDWR);
close_fd = use_fd;
if (use_fd == -1) {
if (use_fd < 0) {
uv__write_int(error_fd, UV__ERR(errno));
_exit(127);
}