Fix compilation error due to 64-bit integer narrowing to size_t (#5250)

This commit is contained in:
Philip Hyunsu Cho
2020-01-30 21:32:15 -08:00
committed by GitHub
parent 472ded549d
commit adc795929a
2 changed files with 5 additions and 4 deletions

View File

@@ -670,9 +670,10 @@ class LearnerImpl : public Learner {
for more details about differences between saving model and serializing.
)doc";
int64_t json_offset {-1};
CHECK_EQ(fp.Read(&json_offset, sizeof(json_offset)), sizeof(json_offset));
CHECK_GT(json_offset, 0);
int64_t sz {-1};
CHECK_EQ(fp.Read(&sz, sizeof(sz)), sizeof(sz));
CHECK_GT(sz, 0);
size_t json_offset = static_cast<size_t>(sz);
std::string buffer;
common::FixedSizeStream{&fp}.Take(&buffer);