mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-27 15:35:18 +00:00
Fix test.
This commit is contained in:
parent
6a5f27bed2
commit
6bd3880cf1
@ -102,9 +102,19 @@ void File::close() {
|
||||
fmt::ThrowSystemError(errno, "cannot close file");
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// On Windows the count argument to read and write is unsigned, so convert
|
||||
// it from size_t preventing integer overflow.
|
||||
inline unsigned ConvertRWCount(std::size_t count) {
|
||||
return count <= UINT_MAX ? count : UINT_MAX;
|
||||
}
|
||||
#else
|
||||
inline std::size_t ConvertRWCount(std::size_t count) { return count; }
|
||||
#endif
|
||||
|
||||
std::streamsize File::read(void *buffer, std::size_t count) {
|
||||
std::streamsize result = 0;
|
||||
FMT_RETRY(result, ::FMT_POSIX(read(fd_, buffer, count)));
|
||||
FMT_RETRY(result, ::FMT_POSIX(read(fd_, buffer, ConvertRWCount(count))));
|
||||
if (result == -1)
|
||||
fmt::ThrowSystemError(errno, "cannot read from file");
|
||||
return result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user