From 7f756955b643fdd2e3b803e1a04d5a0f3095e41b Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sat, 24 Aug 2013 15:40:53 +0200 Subject: [PATCH] windows: make uv_fs_chmod() report errors correctly Before this patch libuv would attempt to use GetLastError() to retrieve the cause of NtQueryInformationFile failure, but that's not how it should be done. --- src/win/fs.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/win/fs.c b/src/win/fs.c index 9d4d7ff8..59de7d8c 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -1069,7 +1069,6 @@ static void fs__chmod(uv_fs_t* req) { static void fs__fchmod(uv_fs_t* req) { int fd = req->fd; - int result; HANDLE handle; NTSTATUS nt_status; IO_STATUS_BLOCK io_status; @@ -1077,7 +1076,7 @@ static void fs__fchmod(uv_fs_t* req) { VERIFY_FD(fd, req); - handle = (HANDLE)_get_osfhandle(fd); + handle = (HANDLE) _get_osfhandle(fd); nt_status = pNtQueryInformationFile(handle, &io_status, @@ -1085,9 +1084,9 @@ static void fs__fchmod(uv_fs_t* req) { sizeof file_info, FileBasicInformation); - if (nt_status != STATUS_SUCCESS) { - result = -1; - goto done; + if (!NT_SUCCESS(nt_status)) { + SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); + return; } if (req->mode & _S_IWRITE) { @@ -1102,15 +1101,12 @@ static void fs__fchmod(uv_fs_t* req) { sizeof file_info, FileBasicInformation); - if (nt_status != STATUS_SUCCESS) { - result = -1; - goto done; + if (!NT_SUCCESS(nt_status)) { + SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); + return; } - result = 0; - -done: - SET_REQ_RESULT(req, result); + SET_REQ_SUCCESS(req); }