summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2022-07-19 16:45:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-19 17:14:34 +0000
commitd36795e47dadb8c324baeef692646232bff1f7c9 (patch)
tree0a549fca6ca3af9c003eb5f16615613d571ebc29
parent24d4538ef2c52ae81455849ca37b40ed51fcc38c (diff)
downloadmongo-d36795e47dadb8c324baeef692646232bff1f7c9.tar.gz
SERVER-68123 Handle unused-but-set-variable warnings
-rw-r--r--src/mongo/db/commands/cpuload.cpp2
-rw-r--r--src/mongo/db/fts/fts_index_format.cpp3
-rw-r--r--src/mongo/db/query/optimizer/explain.cpp3
-rw-r--r--src/mongo/db/storage/key_string.cpp7
-rw-r--r--src/mongo/shell/bench.cpp2
-rw-r--r--src/third_party/benchmark/SConscript3
-rw-r--r--src/third_party/timelib-2021.06/SConscript3
7 files changed, 8 insertions, 15 deletions
diff --git a/src/mongo/db/commands/cpuload.cpp b/src/mongo/db/commands/cpuload.cpp
index 23279a4b688..400cdc3a4d8 100644
--- a/src/mongo/db/commands/cpuload.cpp
+++ b/src/mongo/db/commands/cpuload.cpp
@@ -72,7 +72,7 @@ public:
}
long long limit = 10000 * cpuFactor;
// volatile used to ensure that loop is not optimized away
- volatile uint64_t lresult = 0; // NOLINT
+ volatile uint64_t lresult [[maybe_unused]] = 0; // NOLINT
uint64_t x = 100;
for (long long i = 0; i < limit; i++) {
x *= 13;
diff --git a/src/mongo/db/fts/fts_index_format.cpp b/src/mongo/db/fts/fts_index_format.cpp
index cb7977cfdcd..3ae911ea641 100644
--- a/src/mongo/db/fts/fts_index_format.cpp
+++ b/src/mongo/db/fts/fts_index_format.cpp
@@ -116,7 +116,6 @@ void FTSIndexFormat::getKeys(SharedBufferFragmentBuilder& pooledBufferBuilder,
KeyString::Version keyStringVersion,
Ordering ordering,
const boost::optional<RecordId>& id) {
- int extraSize = 0;
vector<BSONElement> extrasBefore;
vector<BSONElement> extrasAfter;
@@ -124,14 +123,12 @@ void FTSIndexFormat::getKeys(SharedBufferFragmentBuilder& pooledBufferBuilder,
for (unsigned i = 0; i < spec.numExtraBefore(); i++) {
auto indexedElement = extractNonFTSKeyElement(obj, spec.extraBefore(i));
extrasBefore.push_back(indexedElement);
- extraSize += indexedElement.size();
}
// Compute the non FTS key elements for the suffix.
for (unsigned i = 0; i < spec.numExtraAfter(); i++) {
auto indexedElement = extractNonFTSKeyElement(obj, spec.extraAfter(i));
extrasAfter.push_back(indexedElement);
- extraSize += indexedElement.size();
}
TermFrequencyMap term_freqs;
diff --git a/src/mongo/db/query/optimizer/explain.cpp b/src/mongo/db/query/optimizer/explain.cpp
index 4c55dffd6ed..a7100e20727 100644
--- a/src/mongo/db/query/optimizer/explain.cpp
+++ b/src/mongo/db/query/optimizer/explain.cpp
@@ -175,7 +175,6 @@ public:
std::ostringstream os;
std::vector<std::string> linePrefix;
- bool firstAddLine = true;
for (const auto& cmd : _cmd) {
switch (cmd._type) {
case CommandType::Indent:
@@ -194,8 +193,6 @@ public:
}
}
os << cmd._str << "\n";
-
- firstAddLine = false;
break;
}
diff --git a/src/mongo/db/storage/key_string.cpp b/src/mongo/db/storage/key_string.cpp
index 0ba7f9c35af..1bb0ce8ac52 100644
--- a/src/mongo/db/storage/key_string.cpp
+++ b/src/mongo/db/storage/key_string.cpp
@@ -2000,10 +2000,6 @@ void readBson(BufReader* reader, bool inverted, Version version) {
}
void filterKeyFromKeyString(uint8_t ctype, BufReader* reader, bool inverted, Version version) {
- // This is only used by the kNumeric.*ByteInt types, but needs to be declared up here
- // since it is used across a fallthrough.
- bool isNegative = false;
-
switch (ctype) {
case CType::kMinKey:
case CType::kMaxKey:
@@ -2106,7 +2102,6 @@ void filterKeyFromKeyString(uint8_t ctype, BufReader* reader, bool inverted, Ver
case CType::kNumericNegativeLargeMagnitude:
inverted = !inverted;
- isNegative = true;
[[fallthrough]]; // format is the same as positive, but inverted
case CType::kNumericPositiveLargeMagnitude: {
uint64_t encoded = readType<uint64_t>(reader, inverted);
@@ -2132,7 +2127,6 @@ void filterKeyFromKeyString(uint8_t ctype, BufReader* reader, bool inverted, Ver
case CType::kNumericNegativeSmallMagnitude:
inverted = !inverted;
- isNegative = true;
[[fallthrough]]; // format is the same as positive, but inverted
case CType::kNumericPositiveSmallMagnitude: {
@@ -2194,7 +2188,6 @@ void filterKeyFromKeyString(uint8_t ctype, BufReader* reader, bool inverted, Ver
case CType::kNumericNegative2ByteInt:
case CType::kNumericNegative1ByteInt:
inverted = !inverted;
- isNegative = true;
[[fallthrough]]; // format is the same as positive, but inverted
case CType::kNumericPositive1ByteInt:
diff --git a/src/mongo/shell/bench.cpp b/src/mongo/shell/bench.cpp
index 0c7b257e5de..e1a0616b9fd 100644
--- a/src/mongo/shell/bench.cpp
+++ b/src/mongo/shell/bench.cpp
@@ -998,7 +998,7 @@ void BenchRunOp::executeOnce(DBClientBase* conn,
// to test underlying system variability.
long long limit = 10000 * this->cpuFactor;
// volatile used to ensure that loop is not optimized away
- volatile uint64_t result = 0; // NOLINT
+ volatile uint64_t result [[maybe_unused]] = 0; // NOLINT
uint64_t x = 100;
for (long long i = 0; i < limit; i++) {
x *= 13;
diff --git a/src/third_party/benchmark/SConscript b/src/third_party/benchmark/SConscript
index 5b11b380ab6..c78879b1001 100644
--- a/src/third_party/benchmark/SConscript
+++ b/src/third_party/benchmark/SConscript
@@ -12,6 +12,9 @@ if env.TargetOSIs('windows'):
env.Append(LIBS=["ShLwApi"])
+if not env.TargetOSIs('windows'):
+ env.AddToCCFLAGSIfSupported('-Wno-unused-but-set-variable')
+
env.Append(
CPPDEFINES=["HAVE_STD_REGEX"],
CXXFLAGS=[] if env.TargetOSIs('windows') else [
diff --git a/src/third_party/timelib-2021.06/SConscript b/src/third_party/timelib-2021.06/SConscript
index 2e69b9150be..3af5bf4e81c 100644
--- a/src/third_party/timelib-2021.06/SConscript
+++ b/src/third_party/timelib-2021.06/SConscript
@@ -38,6 +38,9 @@ try:
'-DHAVE_UNISTD_H',
'-D_GNU_SOURCE',
])
+
+ if not env.TargetOSIs('windows'):
+ env.AddToCCFLAGSIfSupported('-Wno-unused-but-set-variable')
except ValueError:
pass