Skip to content

Commit

Permalink
Fix unused var warnings in Release mode
Browse files Browse the repository at this point in the history
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 facebook#3048

Differential Revision: D6126272

Pulled By: maysamyabandeh

fbshipit-source-id: 4907865db45fd75a39a15725c0695aaa17509c1f
  • Loading branch information
yuslepukhin authored and facebook-github-bot committed Oct 23, 2017
1 parent 63822eb commit d2a65c5
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 19 deletions.
3 changes: 2 additions & 1 deletion db/column_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
12 changes: 6 additions & 6 deletions db/compaction_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions db/db_impl_compaction_flush.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SequenceNumber> snapshot_seqs =
snapshots_.GetAll(&earliest_write_conflict_snapshot);
Expand Down
3 changes: 2 additions & 1 deletion db/version_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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--) {
Expand Down
3 changes: 2 additions & 1 deletion env/mock_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down
3 changes: 2 additions & 1 deletion monitoring/thread_status_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion port/win/env_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions port/win/io_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1020,7 +1021,8 @@ Status WinDirectory::Fsync() { return Status::OK(); }
/// WinFileLock

WinFileLock::~WinFileLock() {
BOOL ret = ::CloseHandle(hFile_);
BOOL ret;
ret = ::CloseHandle(hFile_);
assert(ret);
}

Expand Down
3 changes: 2 additions & 1 deletion utilities/blob_db/blob_db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,8 @@ Status BlobDBImpl::CloseBlobFile(std::shared_ptr<BlobFile> 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(),
Expand Down
3 changes: 2 additions & 1 deletion utilities/document/json_document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ void InitJSONDocument(std::unique_ptr<char[]>* 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);
Expand Down
3 changes: 2 additions & 1 deletion utilities/persistent_cache/block_cache_tier_metadata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion utilities/write_batch_with_index/write_batch_with_index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d2a65c5

Please sign in to comment.