Fix warnings.

This commit is contained in:
Victor Zverovich 2014-05-06 08:13:28 -07:00
parent 5cf3b6dc7d
commit eb09e58697
2 changed files with 7 additions and 3 deletions

View File

@ -148,7 +148,8 @@ std::string GetSystemErrorMessage(int error_code) {
enum { BUFFER_SIZE = 200 };
char buffer[BUFFER_SIZE];
EXPECT_EQ(0, strerror_s(buffer, BUFFER_SIZE, error_code));
EXPECT_LT(std::strlen(buffer), BUFFER_SIZE - 1);
std::size_t max_len = BUFFER_SIZE - 1;
EXPECT_LT(std::strlen(buffer), max_len);
return buffer;
#endif
}

View File

@ -262,7 +262,8 @@ std::string Read(File &f, std::size_t count) {
std::size_t offset = 0;
do {
n = f.read(&buffer[offset], count - offset);
offset += n;
// We can't read more than size_t bytes since count has type size_t.
offset += static_cast<std::size_t>(n);
} while (offset < count && n != 0);
buffer.resize(offset);
return buffer;
@ -275,7 +276,9 @@ void Write(File &f, fmt::StringRef s) {
do {
std::streamsize count = f.write(ptr, num_chars_left);
ptr += count;
num_chars_left -= count;
// We can't write more than size_t bytes since num_chars_left
// has type size_t.
num_chars_left -= static_cast<std::size_t>(count);
} while (num_chars_left != 0);
}