From: Peter Griess Date: Fri, 24 Jan 2014 15:42:00 +0000 (-0800) Subject: Handle platforms where off_t is not convertible to size_t X-Git-Tag: v0.22.0~719 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8cb35a9efa534779a0c469f00ddb65961a657278;p=folly.git Handle platforms where off_t is not convertible to size_t Summary: - On iOS, off_t is an int64_t, and as such std::min() doesn't compile since the types don't match. Normalize to size_t and fail with an error if this conversion can't be made Test Plan: - fbconfig -r folly && fbmake runtests - Built on iOS Reviewed By: tudorb@fb.com FB internal diff: D1142795 --- diff --git a/folly/FileUtil.h b/folly/FileUtil.h index 49398033..d674dc2e 100644 --- a/folly/FileUtil.h +++ b/folly/FileUtil.h @@ -17,6 +17,7 @@ #ifndef FOLLY_FILEUTIL_H_ #define FOLLY_FILEUTIL_H_ +#include "folly/Conv.h" #include "folly/Portability.h" #include "folly/ScopeGuard.h" @@ -144,7 +145,7 @@ bool readFile(const char* file_name, Container& out, constexpr size_t initialAlloc = 1024 * 4; out.resize( std::min( - buf.st_size ? buf.st_size + 1 : initialAlloc, + buf.st_size > 0 ? folly::to(buf.st_size + 1) : initialAlloc, num_bytes)); while (soFar < out.size()) {