From c16b08742738048889192ee3bf10e0635e603646 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 26 Nov 2019 21:40:16 -0800 Subject: [PATCH] Work around weird unused errors with Mingw (#6075) Summary: From the reset of the code, it looks this this maybe can be unconditionally given the attribute? But I couldn't test with MSVC so I defensively put under CPP. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6075 Differential Revision: D18723749 fbshipit-source-id: 45fc8732c28dd29aab1644225d68f3c6f39bd69b --- port/win/io_win.cc | 7 ++++++- port/win/win_thread.cc | 7 ++++++- util/status.cc | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/port/win/io_win.cc b/port/win/io_win.cc index e050d69ddc..c433e5e522 100644 --- a/port/win/io_win.cc +++ b/port/win/io_win.cc @@ -1025,7 +1025,12 @@ Status WinRandomRWFile::Close() { ////////////////////////////////////////////////////////////////////////// /// WinMemoryMappedBufer WinMemoryMappedBuffer::~WinMemoryMappedBuffer() { - BOOL ret = FALSE; + BOOL ret +#if defined(_MSC_VER) + = FALSE; +#else + __attribute__((__unused__)); +#endif if (base_ != nullptr) { ret = ::UnmapViewOfFile(base_); assert(ret); diff --git a/port/win/win_thread.cc b/port/win/win_thread.cc index 9a976e2c6b..34e54f3017 100644 --- a/port/win/win_thread.cc +++ b/port/win/win_thread.cc @@ -138,7 +138,12 @@ void WindowsThread::join() { "WaitForSingleObjectFailed: thread join"); } - BOOL rc; + BOOL rc +#if defined(_MSC_VER) + = FALSE; +#else + __attribute__((__unused__)); +#endif rc = CloseHandle(reinterpret_cast(data_->handle_)); assert(rc != 0); data_->handle_ = 0; diff --git a/util/status.cc b/util/status.cc index 0b1b249353..d75f9271eb 100644 --- a/util/status.cc +++ b/util/status.cc @@ -21,7 +21,12 @@ const char* Status::CopyState(const char* state) { #ifdef OS_WIN const size_t cch = std::strlen(state) + 1; // +1 for the null terminator char* result = new char[cch]; - errno_t ret; + errno_t ret +#if defined(_MSC_VER) + ; +#else + __attribute__((__unused__)); +#endif ret = strncpy_s(result, cch, state, cch - 1); result[cch - 1] = '\0'; assert(ret == 0);