windows/fs: make uv_fs_open() report EINVAL correctly

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.
This commit is contained in:
Bert Belder 2013-09-05 08:46:16 +02:00
parent 0f3c910c1b
commit 489fb4c972

View File

@ -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) {
@ -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;
@ -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. */
@ -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) {