Skip to content

Commit

Permalink
unix: handle uv__open_cloexec return value correctly
Browse files Browse the repository at this point in the history
`uv__open_cloexec()` already returns a libuv error code in case
of failure, and not `-1` like syscalls do.

Fixes: nodejs/help#2099
  • Loading branch information
addaleax committed Jan 21, 2020
1 parent c681117 commit b3e8144
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/unix/linux-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ static uint64_t uv__read_proc_meminfo(const char* what) {
rc = 0;
fd = uv__open_cloexec("/proc/meminfo", O_RDONLY);

if (fd == -1)
if (fd < 0)
return 0;

n = read(fd, buf, sizeof(buf) - 1);
Expand Down
4 changes: 2 additions & 2 deletions src/unix/random-devurandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ int uv__random_readpath(const char* path, void* buf, size_t buflen) {

fd = uv__open_cloexec(path, O_RDONLY);

if (fd == -1)
return UV__ERR(errno);
if (fd < 0)
return fd;

if (fstat(fd, &s)) {
uv__close(fd);
Expand Down

0 comments on commit b3e8144

Please sign in to comment.