From 146b7718f021782b1573b82c8a6f5c6bc90ac2f1 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Wed, 17 May 2017 22:49:15 -0700 Subject: [PATCH] Fix mingw compilation with -DNDEBUG Summary: This was exposed by a48a62d, which made NDEBUG the default for cmake builds. Closes https://github.com/facebook/rocksdb/pull/2315 Differential Revision: D5079583 Pulled By: sagar0 fbshipit-source-id: c614e96a40df016a834a62b6236852265e7ee4db --- port/win/env_win.cc | 14 ++++++++++---- port/win/io_win.cc | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 8a15d04c3..3b56545b7 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -1079,13 +1079,19 @@ std::string Env::GenerateUniqueId() { UuidCreateSequential(&uuid); RPC_CSTR rpc_str; - auto status = UuidToStringA(&uuid, &rpc_str); - assert(status == RPC_S_OK); +#ifndef NDEBUG + assert(UuidToStringA(&uuid, &rpc_str) == RPC_S_OK); +#else + UuidToStringA(&uuid, &rpc_str); +#endif result = reinterpret_cast(rpc_str); - status = RpcStringFreeA(&rpc_str); - assert(status == RPC_S_OK); +#ifndef NDEBUG + assert(RpcStringFreeA(&rpc_str) == RPC_S_OK); +#else + RpcStringFreeA(&rpc_str); +#endif return result; } diff --git a/port/win/io_win.cc b/port/win/io_win.cc index 73b4e0a1e..0b0eccfce 100644 --- a/port/win/io_win.cc +++ b/port/win/io_win.cc @@ -32,7 +32,7 @@ bool IsPowerOfTwo(const size_t alignment) { } inline -bool IsSectorAligned(const size_t off) { +bool IsSectorAligned(const size_t off) { return (off & (kSectorSize - 1)) == 0; } @@ -194,11 +194,13 @@ WinMmapReadableFile::WinMmapReadableFile(const std::string& fileName, length_(length) {} WinMmapReadableFile::~WinMmapReadableFile() { - BOOL ret = ::UnmapViewOfFile(mapped_region_); - assert(ret); - - ret = ::CloseHandle(hMap_); - assert(ret); +#ifndef NDEBUG + assert(::UnmapViewOfFile(mapped_region_)); + assert(::CloseHandle(hMap_)); +#else + ::UnmapViewOfFile(mapped_region_); + ::CloseHandle(hMap_); +#endif } Status WinMmapReadableFile::Read(uint64_t offset, size_t n, Slice* result, @@ -745,7 +747,9 @@ Status WinWritableImpl::AppendImpl(const Slice& data) { assert(data.size() < std::numeric_limits::max()); +#ifndef NDEBUG uint64_t written = 0; +#endif if (file_data_->use_direct_io()) { @@ -765,7 +769,9 @@ Status WinWritableImpl::AppendImpl(const Slice& data) { "Failed to pwrite for: " + file_data_->GetName(), lastError); } else { +#ifndef NDEBUG written = ret; +#endif } } else { @@ -779,7 +785,9 @@ Status WinWritableImpl::AppendImpl(const Slice& data) { lastError); } else { +#ifndef NDEBUG written = bytesWritten; +#endif } }