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.
This commit is contained in:
Paul "TBBle" Hampson
2018-01-08 13:03:56 +11:00
committed by Vinnie Falco
parent 035248cefb
commit 0efc246466
3 changed files with 8 additions and 7 deletions

View File

@@ -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
--------------------------------------------------------------------------------

View File

@@ -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;

View File

@@ -25,6 +25,7 @@
#include <boost/make_unique.hpp>
#include <boost/smart_ptr/make_shared_array.hpp>
#include <boost/winapi/basic_types.hpp>
#include <boost/winapi/get_last_error.hpp>
#include <algorithm>
#include <cstring>
@@ -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<int>(
boost::winapi::GetLastError()),
overlapped.complete(error_code{static_cast<int>(dwError),
system_category()}, 0);
return;
}