summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsuzker <szhiliang@gmail.com>2016-05-25 07:43:57 -0700
committersuzker <szhiliang@gmail.com>2016-05-25 07:43:57 -0700
commitef0a2e601f64904b87cf56244e5600a1c6baa3e9 (patch)
tree326be7e926671d267591edec302ec5cdd1d62516 /src
parent43aea5c9402ff0a4c2bc8365ea9aa2ff3447a356 (diff)
Compare filesize directly to the numeric max of size_t
Diffstat (limited to 'src')
-rw-r--r--src/AbstractDiskWriter.cc3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc
index df2d0a85..9e3dac4b 100644
--- a/src/AbstractDiskWriter.cc
+++ b/src/AbstractDiskWriter.cc
@@ -373,8 +373,7 @@ void AbstractDiskWriter::ensureMmapWrite(size_t len, int64_t offset)
return;
}
- uint32_t filesize_lo = filesize & 0xffffffffu;
- if (sizeof(off_t) > sizeof(size_t) && (filesize_lo) > 0) {
+ if (static_cast<uint64_t>(std::numeric_limits<size_t>::max()) < static_cast<uint64_t>(filesize)) {
// filesize could overflow in 32bit OS with 64bit off_t type
// the filesize will be truncated if provided as a 32bit size_t
enableMmap_ = false;