From 8cb35a9efa534779a0c469f00ddb65961a657278 Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Fri, 24 Jan 2014 07:42:00 -0800 Subject: [PATCH] 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 --- folly/FileUtil.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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()) { -- 2.34.1