From ef0a2e601f64904b87cf56244e5600a1c6baa3e9 Mon Sep 17 00:00:00 2001 From: suzker Date: Wed, 25 May 2016 07:43:57 -0700 Subject: [PATCH] Compare filesize directly to the numeric max of size_t --- src/AbstractDiskWriter.cc | 3 +-- 1 file changed, 1 insertion(+), 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(std::numeric_limits::max()) < static_cast(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;