From 0efc246466444d41f35713c26433eb3dd7d94e75 Mon Sep 17 00:00:00 2001 From: "Paul \"TBBle\" Hampson" Date: Mon, 8 Jan 2018 13:03:56 +1100 Subject: [PATCH] Use boost::winapi::GetLastError() consistently: This replaces a few direct calls to ::GetLastError, and also removes a couple of duplicate calls when the value was already held locally. --- CHANGELOG.md | 1 + include/boost/beast/core/impl/file_win32.ipp | 8 ++++---- include/boost/beast/http/impl/file_body_win32.ipp | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d280b42..03dca5f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 153: * Remove BOOST_VERSION checks * Use make_error_code for setting an error_code from errc +* Use boost::winapi::GetLastError() consistently -------------------------------------------------------------------------------- diff --git a/include/boost/beast/core/impl/file_win32.ipp b/include/boost/beast/core/impl/file_win32.ipp index ad7f255e..c1b4cc6c 100644 --- a/include/boost/beast/core/impl/file_win32.ipp +++ b/include/boost/beast/core/impl/file_win32.ipp @@ -300,9 +300,9 @@ read(void* buffer, std::size_t n, error_code& ec) boost::winapi::DWORD_ bytesRead; if(! ::ReadFile(h_, buffer, amount, &bytesRead, 0)) { - auto const dwError = ::GetLastError(); + auto const dwError = boost::winapi::GetLastError(); if(dwError != boost::winapi::ERROR_HANDLE_EOF_) - ec.assign(::GetLastError(), system_category()); + ec.assign(dwError, system_category()); else ec.assign(0, ec.category()); return nread; @@ -341,9 +341,9 @@ write(void const* buffer, std::size_t n, error_code& ec) boost::winapi::DWORD_ bytesWritten; if(! ::WriteFile(h_, buffer, amount, &bytesWritten, 0)) { - auto const dwError = ::GetLastError(); + auto const dwError = boost::winapi::GetLastError(); if(dwError != boost::winapi::ERROR_HANDLE_EOF_) - ec.assign(::GetLastError(), system_category()); + ec.assign(dwError, system_category()); else ec.assign(0, ec.category()); return nwritten; diff --git a/include/boost/beast/http/impl/file_body_win32.ipp b/include/boost/beast/http/impl/file_body_win32.ipp index 6d2a82ec..9e4cfaf8 100644 --- a/include/boost/beast/http/impl/file_body_win32.ipp +++ b/include/boost/beast/http/impl/file_body_win32.ipp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -436,14 +437,13 @@ operator()() overlapped.get(), nullptr, 0); - auto const dwError = ::GetLastError(); + auto const dwError = boost::winapi::GetLastError(); if(! bSuccess && dwError != boost::winapi::ERROR_IO_PENDING_) { // VFALCO This needs review, is 0 the right number? // completed immediately (with error?) - overlapped.complete(error_code{static_cast( - boost::winapi::GetLastError()), + overlapped.complete(error_code{static_cast(dwError), system_category()}, 0); return; }