From d2a65c59e1ae270822c4c56176a7d1dcfb8e2033 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 23 Oct 2017 14:20:53 -0700 Subject: [PATCH] Fix unused var warnings in Release mode Summary: MSVC does not support unused attribute at this time. A separate assignment line fixes the issue probably by being counted as usage for MSVC and it no longer complains about unused var. Closes https://github.com/facebook/rocksdb/pull/3048 Differential Revision: D6126272 Pulled By: maysamyabandeh fbshipit-source-id: 4907865db45fd75a39a15725c0695aaa17509c1f --- db/column_family.cc | 3 ++- db/compaction_iterator.cc | 12 ++++++------ db/db_impl_compaction_flush.cc | 4 ++-- db/version_set.cc | 3 ++- env/mock_env.cc | 3 ++- monitoring/thread_status_updater.cc | 3 ++- port/win/env_win.cc | 4 +++- port/win/io_win.cc | 6 ++++-- utilities/blob_db/blob_db_impl.cc | 3 ++- utilities/document/json_document.cc | 3 ++- .../persistent_cache/block_cache_tier_metadata.cc | 3 ++- .../write_batch_with_index/write_batch_with_index.cc | 3 ++- 12 files changed, 31 insertions(+), 19 deletions(-) diff --git a/db/column_family.cc b/db/column_family.cc index 367d4b608..e5a27dc8f 100644 --- a/db/column_family.cc +++ b/db/column_family.cc @@ -463,7 +463,8 @@ ColumnFamilyData::~ColumnFamilyData() { if (dummy_versions_ != nullptr) { // List must be empty assert(dummy_versions_->TEST_Next() == dummy_versions_); - bool deleted __attribute__((unused)) = dummy_versions_->Unref(); + bool deleted __attribute__((unused)); + deleted = dummy_versions_->Unref(); assert(deleted); } diff --git a/db/compaction_iterator.cc b/db/compaction_iterator.cc index fe29460a4..6de962ab4 100644 --- a/db/compaction_iterator.cc +++ b/db/compaction_iterator.cc @@ -137,8 +137,8 @@ void CompactionIterator::Next() { if (merge_out_iter_.Valid()) { key_ = merge_out_iter_.key(); value_ = merge_out_iter_.value(); - bool valid_key __attribute__((__unused__)) = - ParseInternalKey(key_, &ikey_); + bool valid_key __attribute__((__unused__)); + valid_key = ParseInternalKey(key_, &ikey_); // MergeUntil stops when it encounters a corrupt key and does not // include them in the result, so we expect the keys here to be valid. assert(valid_key); @@ -334,8 +334,8 @@ void CompactionIterator::NextFromInput() { // If there are no snapshots, then this kv affect visibility at tip. // Otherwise, search though all existing snapshots to find the earliest // snapshot that is affected by this kv. - SequenceNumber last_sequence __attribute__((__unused__)) = - current_user_key_sequence_; + SequenceNumber last_sequence __attribute__((__unused__)); + last_sequence = current_user_key_sequence_; current_user_key_sequence_ = ikey_.sequence; SequenceNumber last_snapshot = current_user_key_snapshot_; SequenceNumber prev_snapshot = 0; // 0 means no previous snapshot @@ -538,8 +538,8 @@ void CompactionIterator::NextFromInput() { // These will be correctly set below. key_ = merge_out_iter_.key(); value_ = merge_out_iter_.value(); - bool valid_key __attribute__((__unused__)) = - ParseInternalKey(key_, &ikey_); + bool valid_key __attribute__((__unused__)); + valid_key = ParseInternalKey(key_, &ikey_); // MergeUntil stops when it encounters a corrupt key and does not // include them in the result, so we expect the keys here to valid. assert(valid_key); diff --git a/db/db_impl_compaction_flush.cc b/db/db_impl_compaction_flush.cc index 5f3239720..4436d3acf 100644 --- a/db/db_impl_compaction_flush.cc +++ b/db/db_impl_compaction_flush.cc @@ -1678,10 +1678,10 @@ Status DBImpl::BackgroundCompaction(bool* made_progress, env_->Schedule(&DBImpl::BGWorkBottomCompaction, ca, Env::Priority::BOTTOM, this, &DBImpl::UnscheduleCallback); } else { - int output_level __attribute__((unused)) = c->output_level(); + int output_level __attribute__((unused)); + output_level = c->output_level(); TEST_SYNC_POINT_CALLBACK("DBImpl::BackgroundCompaction:NonTrivial", &output_level); - SequenceNumber earliest_write_conflict_snapshot; std::vector snapshot_seqs = snapshots_.GetAll(&earliest_write_conflict_snapshot); diff --git a/db/version_set.cc b/db/version_set.cc index 892f6d969..348b07ad1 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -1912,7 +1912,8 @@ void VersionStorageInfo::ExtendFileRangeOverlappingInterval( #endif *start_index = mid_index + 1; *end_index = mid_index; - int count __attribute__((unused)) = 0; + int count __attribute__((unused)); + count = 0; // check backwards from 'mid' to lower indices for (int i = mid_index; i >= 0 ; i--) { diff --git a/env/mock_env.cc b/env/mock_env.cc index 669011c4e..4e46b467f 100644 --- a/env/mock_env.cc +++ b/env/mock_env.cc @@ -379,7 +379,8 @@ class TestMemLogger : public Logger { const time_t seconds = now_tv.tv_sec; struct tm t; memset(&t, 0, sizeof(t)); - auto ret __attribute__((__unused__)) = localtime_r(&seconds, &t); + struct tm* ret __attribute__((__unused__)); + ret = localtime_r(&seconds, &t); assert(ret); p += snprintf(p, limit - p, "%04d/%02d/%02d-%02d:%02d:%02d.%06d ", diff --git a/monitoring/thread_status_updater.cc b/monitoring/thread_status_updater.cc index 67a42be16..78c8afa1c 100644 --- a/monitoring/thread_status_updater.cc +++ b/monitoring/thread_status_updater.cc @@ -252,7 +252,8 @@ void ThreadStatusUpdater::EraseColumnFamilyInfo(const void* cf_key) { ConstantColumnFamilyInfo& cf_info = cf_pair->second; auto db_pair = db_key_map_.find(cf_info.db_key); assert(db_pair != db_key_map_.end()); - size_t result __attribute__((unused)) = db_pair->second.erase(cf_key); + size_t result __attribute__((unused)); + result = db_pair->second.erase(cf_key); assert(result); cf_info_map_.erase(cf_pair); } diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 462148893..3e84d06bd 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -74,7 +74,9 @@ WinEnvIO::WinEnvIO(Env* hosted_env) { LARGE_INTEGER qpf; - BOOL ret = QueryPerformanceFrequency(&qpf); + // No init as the compiler complains about unused var + BOOL ret; + ret = QueryPerformanceFrequency(&qpf); assert(ret == TRUE); perf_counter_frequency_ = qpf.QuadPart; } diff --git a/port/win/io_win.cc b/port/win/io_win.cc index d68c412a3..9403c829d 100644 --- a/port/win/io_win.cc +++ b/port/win/io_win.cc @@ -279,7 +279,8 @@ Status WinMmapFile::MapNewRegion() { if (hMap_ != NULL) { // Unmap the previous one - BOOL ret = ::CloseHandle(hMap_); + BOOL ret; + ret = ::CloseHandle(hMap_); assert(ret); hMap_ = NULL; } @@ -1020,7 +1021,8 @@ Status WinDirectory::Fsync() { return Status::OK(); } /// WinFileLock WinFileLock::~WinFileLock() { - BOOL ret = ::CloseHandle(hFile_); + BOOL ret; + ret = ::CloseHandle(hFile_); assert(ret); } diff --git a/utilities/blob_db/blob_db_impl.cc b/utilities/blob_db/blob_db_impl.cc index aefa2598b..166f11009 100644 --- a/utilities/blob_db/blob_db_impl.cc +++ b/utilities/blob_db/blob_db_impl.cc @@ -1312,7 +1312,8 @@ Status BlobDBImpl::CloseBlobFile(std::shared_ptr bfile) { WriteLock wl(&mutex_); if (bfile->HasTTL()) { - size_t erased __attribute__((__unused__)) = open_blob_files_.erase(bfile); + size_t erased __attribute__((__unused__)); + erased = open_blob_files_.erase(bfile); assert(erased == 1); } else { auto iter = std::find(open_simple_files_.begin(), diff --git a/utilities/document/json_document.cc b/utilities/document/json_document.cc index 6917923a3..fe7fbab16 100644 --- a/utilities/document/json_document.cc +++ b/utilities/document/json_document.cc @@ -48,7 +48,8 @@ void InitJSONDocument(std::unique_ptr* data, fbson::FbsonWriter writer; bool res __attribute__((unused)) = writer.writeStartArray(); assert(res); - uint32_t bytesWritten __attribute__((unused)) = f(writer); + uint32_t bytesWritten __attribute__((unused)); + bytesWritten = f(writer); assert(bytesWritten != 0); res = writer.writeEndArray(); assert(res); diff --git a/utilities/persistent_cache/block_cache_tier_metadata.cc b/utilities/persistent_cache/block_cache_tier_metadata.cc index 84d901bc4..3382fda31 100644 --- a/utilities/persistent_cache/block_cache_tier_metadata.cc +++ b/utilities/persistent_cache/block_cache_tier_metadata.cc @@ -63,7 +63,8 @@ bool BlockCacheTierMetadata::Lookup(const Slice& key, LBA* lba) { BlockInfo* BlockCacheTierMetadata::Remove(const Slice& key) { BlockInfo lookup_key(key); BlockInfo* binfo = nullptr; - bool ok __attribute__((__unused__)) = block_index_.Erase(&lookup_key, &binfo); + bool ok __attribute__((__unused__)); + ok = block_index_.Erase(&lookup_key, &binfo); assert(ok); return binfo; } diff --git a/utilities/write_batch_with_index/write_batch_with_index.cc b/utilities/write_batch_with_index/write_batch_with_index.cc index d63f5f7b0..133419aa3 100644 --- a/utilities/write_batch_with_index/write_batch_with_index.cc +++ b/utilities/write_batch_with_index/write_batch_with_index.cc @@ -480,7 +480,8 @@ void WriteBatchWithIndex::Rep::AddNewEntry(uint32_t column_family_id) { wb_data.size() - last_entry_offset); // Extract key Slice key; - bool success __attribute__((__unused__)) = + bool success __attribute__((__unused__)); + success = ReadKeyFromWriteBatchEntry(&entry_ptr, &key, column_family_id != 0); assert(success);