mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
Use make_error_code for setting an error_code from errc:
In Boost.System, `boost::system::errc` is a namespace containing ints. In C++11, std::errc is an enum marked as an `error_condition`. `error_code::assign` is specified as taking an int only, while make_error_code is able to deal correctly with both forms.
This commit is contained in:
committed by
Vinnie Falco
parent
3546eff033
commit
035248cefb
@@ -1,6 +1,7 @@
|
|||||||
Version 153:
|
Version 153:
|
||||||
|
|
||||||
* Remove BOOST_VERSION checks
|
* Remove BOOST_VERSION checks
|
||||||
|
* Use make_error_code for setting an error_code from errc
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -224,7 +224,7 @@ size(error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(fd_ == -1)
|
if(fd_ == -1)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@@ -244,7 +244,7 @@ pos(error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(fd_ == -1)
|
if(fd_ == -1)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto const result = ::lseek(fd_, 0, SEEK_CUR);
|
auto const result = ::lseek(fd_, 0, SEEK_CUR);
|
||||||
@@ -264,7 +264,7 @@ seek(std::uint64_t offset, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(fd_ == -1)
|
if(fd_ == -1)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto const result = ::lseek(fd_, offset, SEEK_SET);
|
auto const result = ::lseek(fd_, offset, SEEK_SET);
|
||||||
@@ -283,7 +283,7 @@ read(void* buffer, std::size_t n, error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(fd_ == -1)
|
if(fd_ == -1)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::size_t nread = 0;
|
std::size_t nread = 0;
|
||||||
@@ -319,7 +319,7 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(fd_ == -1)
|
if(fd_ == -1)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::size_t nwritten = 0;
|
std::size_t nwritten = 0;
|
||||||
|
@@ -122,7 +122,7 @@ size(error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(! f_)
|
if(! f_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
long pos = std::ftell(f_);
|
long pos = std::ftell(f_);
|
||||||
@@ -159,7 +159,7 @@ pos(error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(! f_)
|
if(! f_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
long pos = std::ftell(f_);
|
long pos = std::ftell(f_);
|
||||||
@@ -179,7 +179,7 @@ seek(std::uint64_t offset, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(! f_)
|
if(! f_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(offset > (std::numeric_limits<long>::max)())
|
if(offset > (std::numeric_limits<long>::max)())
|
||||||
@@ -202,7 +202,7 @@ read(void* buffer, std::size_t n, error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(! f_)
|
if(! f_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto nread = std::fread(buffer, 1, n, f_);
|
auto nread = std::fread(buffer, 1, n, f_);
|
||||||
@@ -221,7 +221,7 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(! f_)
|
if(! f_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
auto nwritten = std::fwrite(buffer, 1, n, f_);
|
auto nwritten = std::fwrite(buffer, 1, n, f_);
|
||||||
|
@@ -216,7 +216,7 @@ size(error_code& ec) const
|
|||||||
{
|
{
|
||||||
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
boost::winapi::LARGE_INTEGER_ fileSize;
|
boost::winapi::LARGE_INTEGER_ fileSize;
|
||||||
@@ -237,7 +237,7 @@ pos(error_code& ec)
|
|||||||
{
|
{
|
||||||
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
boost::winapi::LARGE_INTEGER_ in;
|
boost::winapi::LARGE_INTEGER_ in;
|
||||||
@@ -261,7 +261,7 @@ seek(std::uint64_t offset, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boost::winapi::LARGE_INTEGER_ in;
|
boost::winapi::LARGE_INTEGER_ in;
|
||||||
@@ -283,7 +283,7 @@ read(void* buffer, std::size_t n, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::size_t nread = 0;
|
std::size_t nread = 0;
|
||||||
@@ -324,7 +324,7 @@ write(void const* buffer, std::size_t n, error_code& ec)
|
|||||||
{
|
{
|
||||||
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
|
||||||
{
|
{
|
||||||
ec.assign(errc::invalid_argument, generic_category());
|
ec = make_error_code(errc::invalid_argument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::size_t nwritten = 0;
|
std::size_t nwritten = 0;
|
||||||
|
Reference in New Issue
Block a user