Skip to content

Commit

Permalink
windows/fs: make uv_fs_open() report EINVAL correctly
Browse files Browse the repository at this point in the history
Before, when the user passed an invalid paramter to uv_fs_open, libuv
would detect this and call SET_REQ_RESULT to set the result value to -1.
SET_REQ_RESULT then stored whatever error code was returned by
GetLastError(), which would have no relationship to the actual problem,
and might as well be zero.
  • Loading branch information
piscisaureus committed Sep 5, 2013
1 parent 0f3c910 commit 489fb4c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ void fs__open(uv_fs_t* req) {
access = FILE_GENERIC_READ | FILE_GENERIC_WRITE;
break;
default:
result = -1;
goto end;
goto einval;
}

if (flags & _O_APPEND) {
Expand Down Expand Up @@ -449,8 +448,7 @@ void fs__open(uv_fs_t* req) {
disposition = CREATE_ALWAYS;
break;
default:
result = -1;
goto end;
goto einval;
}

attributes |= FILE_ATTRIBUTE_NORMAL;
Expand Down Expand Up @@ -479,8 +477,7 @@ void fs__open(uv_fs_t* req) {
attributes |= FILE_FLAG_RANDOM_ACCESS;
break;
default:
result = -1;
goto end;
goto einval;
}

/* Setting this flag makes it possible to open a directory. */
Expand All @@ -506,8 +503,11 @@ void fs__open(uv_fs_t* req) {
return;
}
result = _open_osfhandle((intptr_t) file, flags);
end:
SET_REQ_RESULT(req, result);
return;

einval:
SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
}

void fs__close(uv_fs_t* req) {
Expand Down

0 comments on commit 489fb4c

Please sign in to comment.