Remove use of POSIX-only constant

fixes #2233
refs #2231
This commit is contained in:
Richard Hodges
2021-05-13 21:06:40 +02:00
parent 30abfdb9f7
commit 5546086ca9
2 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,7 @@
* Remove use of POSIX-only constant.
--------------------------------------------------------------------------------
Version 317: Version 317:
* Remove travis CI. * Remove travis CI.

View File

@ -270,8 +270,12 @@ read(void* buffer, std::size_t n, error_code& ec) const
std::size_t nread = 0; std::size_t nread = 0;
while(n > 0) while(n > 0)
{ {
auto const amount = static_cast<ssize_t>((std::min)( // <limits> not required to define SSIZE_MAX so we avoid it
n, static_cast<std::size_t>(SSIZE_MAX))); constexpr auto ssmax =
static_cast<std::size_t>((std::numeric_limits<
decltype(::read(fd_, buffer, n))>::max)());
auto const amount = (std::min)(
n, ssmax);
auto const result = ::read(fd_, buffer, amount); auto const result = ::read(fd_, buffer, amount);
if(result == -1) if(result == -1)
{ {
@ -305,8 +309,12 @@ write(void const* buffer, std::size_t n, error_code& ec)
std::size_t nwritten = 0; std::size_t nwritten = 0;
while(n > 0) while(n > 0)
{ {
auto const amount = static_cast<ssize_t>((std::min)( // <limits> not required to define SSIZE_MAX so we avoid it
n, static_cast<std::size_t>(SSIZE_MAX))); constexpr auto ssmax =
static_cast<std::size_t>((std::numeric_limits<
decltype(::write(fd_, buffer, n))>::max)());
auto const amount = (std::min)(
n, ssmax);
auto const result = ::write(fd_, buffer, amount); auto const result = ::write(fd_, buffer, amount);
if(result == -1) if(result == -1)
{ {