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 39bef32906
commit 812717d0dd

View File

@ -421,8 +421,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) {
@ -459,8 +458,7 @@ void fs__open(uv_fs_t* req) {
disposition = CREATE_ALWAYS;
break;
default:
result = -1;
goto end;
goto einval;
}
attributes |= FILE_ATTRIBUTE_NORMAL;
@ -489,8 +487,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. */
@ -516,8 +513,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);
}