Skip to content

Commit

Permalink
Fixed the data loss warnings from MSVC in the stream code as we happe…
Browse files Browse the repository at this point in the history
…n to be safe in this case
  • Loading branch information
dragonmux committed Sep 30, 2018
1 parent 4f34a44 commit 8d03ea9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Stream.cpp
Expand Up @@ -47,7 +47,11 @@ bool fileStream_t::read(void *const value, const size_t valueLen, size_t &actual
// If write-only and not read-write mode, or we got to eof.. return false.
if (eof || ((mode & O_WRONLY) && !(mode & O_RDWR)))
return false;
#ifndef _MSC_VER
ssize_t ret = ::read(fd, value, valueLen);
#else
ssize_t ret = ::read(fd, value, uint32_t(valueLen));
#endif
if (ret < 0)
throw std::system_error(errno, std::system_category());
// This call sets EOF for us.
Expand All @@ -61,7 +65,11 @@ bool fileStream_t::write(const void *const value, const size_t valueLen)
// If read-only and not read-write mode, or we ran out of space.. return false.
if (eof || !(mode & (O_WRONLY | O_RDWR)))
return false;
#ifndef _MSC_VER
ssize_t ret = ::write(fd, value, valueLen);
#else
ssize_t ret = ::write(fd, value, uint32_t(valueLen));
#endif
if (ret < 0)
throw std::system_error(errno, std::system_category());
eof = ret == 0;
Expand Down

0 comments on commit 8d03ea9

Please sign in to comment.