From 812717d0dda831594f91126272b7f5b3e323e184 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 5 Sep 2013 08:46:16 +0200 Subject: [PATCH] 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. --- src/win/fs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/win/fs.c b/src/win/fs.c index 2b9e6135d..f0ceb0925 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -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); }