Skip to content

Commit 6d6f78e

Browse files
auto-revert-app[bot]MongoDB Bot
authored and
MongoDB Bot
committed
Revert "SERVER-95859 Fix -Wmissing-prototypes warnings and enable it (#28170)" (#29184)
GitOrigin-RevId: 0c35f7647358a7e2116cbc4481996c524ff17409
1 parent a3c59a2 commit 6d6f78e

File tree

422 files changed

+2423
-989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

422 files changed

+2423
-989
lines changed

bazel/toolchains/mongo_cc_toolchain_config.bzl

-22
Original file line numberDiff line numberDiff line change
@@ -687,27 +687,6 @@ def _impl(ctx):
687687
],
688688
)
689689

690-
# Warn about global functions being defined without a definition, which
691-
# usually indicates an unintentionally extern helper. Note that clang's
692-
# `-Wmissing-declarations` is a very different warning.
693-
if ctx.attr.compiler == "clang":
694-
missing_proto_flag = [flag_group(flags = ["-Wmissing-prototypes"])]
695-
elif ctx.attr.compiler == "gcc":
696-
missing_proto_flag = [flag_group(flags = ["-Wmissing-declarations"])]
697-
else:
698-
missing_proto_flag = []
699-
700-
missing_prototypes_feature = feature(
701-
name = "missing_prototypes_warning",
702-
enabled = True,
703-
flag_sets = [
704-
flag_set(
705-
actions = all_cpp_compile_actions,
706-
flag_groups = missing_proto_flag,
707-
),
708-
],
709-
)
710-
711690
features = [
712691
bin_dirs_feature,
713692
default_compile_flags_feature,
@@ -746,7 +725,6 @@ def _impl(ctx):
746725
overloaded_virtual_warning_feature,
747726
no_overloaded_virtual_warning_feature,
748727
pessimizing_move_warning_feature,
749-
missing_prototypes_feature,
750728
]
751729

752730
return [

src/SConscript

-5
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,8 @@ if env.ToolchainIs("gcc"):
6363
# With GCC, use the implicit fallthrough flag variant that doesn't
6464
# care about your feeble attempts to use comments to explain yourself.
6565
env.AddToCCFLAGSIfSupported("-Wimplicit-fallthrough=5")
66-
env.AddToCCFLAGSIfSupported("-Wmissing-declarations")
6766
elif env.ToolchainIs("clang"):
6867
env.AddToCCFLAGSIfSupported("-Wimplicit-fallthrough")
69-
# Clang's -Wmissing-prototypes is equivalent to GCC's
70-
# -Wmissing-declarations, while Clang's -Wmissing-declarations checks
71-
# something different.
72-
env.AddToCCFLAGSIfSupported("-Wmissing-prototypes")
7368

7469
# Run the core mongodb SConscript.
7570
env.SConscript("mongo/SConscript", must_exist=1, exports=["env"])

src/mongo/base/clonable_ptr_test.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,6 @@ TEST(ClonablePtrTest, ownershipStabilityTest) {
842842
}
843843
}
844844

845-
namespace {
846845
class ClonableObject {
847846
private:
848847
int value = 0;
@@ -868,7 +867,6 @@ bool operator==(const ClonableObject& lhs, const ClonableObject& rhs) {
868867
bool operator!=(const ClonableObject& lhs, const ClonableObject& rhs) {
869868
return !(lhs == rhs);
870869
}
871-
} // namespace
872870

873871
TEST(ClonablePtrTest, noObjectCopySemanticTest) {
874872
mongo::clonable_ptr<ClonableObject> p;

src/mongo/base/string_data_test.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,16 @@ TEST(Rfind, Char1) {
296296
}
297297
}
298298

299+
// this is to verify we match std::string
300+
void SUBSTR_TEST_HELP(StringData big, StringData small, size_t start, size_t len) {
301+
ASSERT_EQUALS(small.toString(), big.toString().substr(start, len));
302+
ASSERT_EQUALS(small, StringData(big).substr(start, len));
303+
}
304+
void SUBSTR_TEST_HELP(StringData big, StringData small, size_t start) {
305+
ASSERT_EQUALS(small.toString(), big.toString().substr(start));
306+
ASSERT_EQUALS(small, StringData(big).substr(start));
307+
}
308+
299309
// [12] is number of args to substr
300310
#define SUBSTR_1_TEST_HELP(big, small, start) \
301311
ASSERT_EQUALS(StringData(small).toString(), StringData(big).toString().substr(start)); \

src/mongo/bson/bson_bin_util.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
namespace mongo {
4343
namespace bson_bin_util {
4444

45-
inline std::string toHex(const char* data, std::size_t len) {
45+
std::string toHex(const char* data, std::size_t len) {
4646
auto rawString = mongo::StringData(data, len);
4747
std::ostringstream hexString;
4848
hexString << std::hex << std::uppercase;
@@ -53,15 +53,15 @@ inline std::string toHex(const char* data, std::size_t len) {
5353
return hexString.str();
5454
}
5555

56-
inline std::string toHex(const BufBuilder& bldr) {
56+
std::string toHex(const BufBuilder& bldr) {
5757
return toHex(static_cast<const char*>(bldr.buf()), static_cast<std::size_t>(bldr.len()));
5858
}
5959

60-
inline std::string toHex(const BSONBinData& binData) {
60+
std::string toHex(const BSONBinData& binData) {
6161
return toHex(static_cast<const char*>(binData.data), static_cast<std::size_t>(binData.length));
6262
}
6363

64-
inline std::string toHex(const BSONObj& obj) {
64+
std::string toHex(const BSONObj& obj) {
6565
return toHex(obj.objdata(), static_cast<std::size_t>(obj.objsize()));
6666
}
6767

src/mongo/bson/bson_bm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ BSONObj buildSampleObj(long long unsigned int i) {
7474
<< "random" << random << "phone_no" << phone_no << "long_string"
7575
<< long_string);
7676
}
77+
} // namespace
7778

7879
void BM_arrayBuilder(benchmark::State& state) {
7980
size_t totalBytes = 0;
@@ -250,7 +251,6 @@ void BM_validate_contents(benchmark::State& state) {
250251
}
251252
state.SetBytesProcessed(totalSize);
252253
}
253-
} // namespace
254254

255255
BENCHMARK(BM_arrayBuilder)->Ranges({{{1}, {100'000}}});
256256
BENCHMARK(BM_arrayLookup)->Ranges({{{1}, {100'000}}});

src/mongo/bson/column/simple8b_bm.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include "mongo/util/shared_buffer.h"
4343

4444
namespace mongo {
45-
namespace {
4645

4746
BufBuilder generateIntegers() {
4847
std::mt19937_64 seedGen(1337);
@@ -282,7 +281,6 @@ void BM_prefixSumUnoptimized(benchmark::State& state) {
282281

283282
state.SetBytesProcessed(totalBytes);
284283
}
285-
} // namespace
286284

287285
BENCHMARK(BM_increasingValues)->Arg(100);
288286
BENCHMARK(BM_rle)->Arg(100);

src/mongo/bson/column/simple8b_type_util_test.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
using namespace mongo;
4545

46-
namespace {
4746
uint8_t scaleIndexForMultiplier(double multiplier) {
4847
auto iterIdx = std::find(Simple8bTypeUtil::kScaleMultiplier.begin(),
4948
Simple8bTypeUtil::kScaleMultiplier.end(),
@@ -85,7 +84,6 @@ void assertStringEqual(StringData val, int128_t expected) {
8584
ASSERT_EQUALS(val.size(), decodeResult.size);
8685
ASSERT_EQUALS(std::memcmp(val.rawData(), decodeResult.str.data(), val.size()), 0);
8786
}
88-
} // namespace
8987

9088
TEST(Simple8bTypeUtil, EncodeAndDecodePositiveSignedInt) {
9189
int64_t signedVal = 1;

src/mongo/bson/mutable/mutable_bson_test.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,22 @@ TEST(OIDType, nullOID) {
812812
ASSERT_EQUALS(withNull, recovered);
813813
}
814814

815+
static const char jsonSample[] =
816+
"{_id:ObjectId(\"47cc67093475061e3d95369d\"),"
817+
"query:\"kate hudson\","
818+
"owner:1234567887654321,"
819+
"date:\"2011-05-13T14:22:46.777Z\","
820+
"score:123.456,"
821+
"field1:Infinity,"
822+
"\"field2\":-Infinity,"
823+
"\"field3\":NaN,"
824+
"users:["
825+
"{uname:\"@aaaa\",editid:\"123\",date:1303959350,yes_votes:0,no_votes:0},"
826+
"{uname:\"@bbbb\",editid:\"456\",date:1303959350,yes_votes:0,no_votes:0},"
827+
"{uname:\"@cccc\",editid:\"789\",date:1303959350,yes_votes:0,no_votes:0}],"
828+
"pattern:/match.*this/,"
829+
"lastfield:\"last\"}";
830+
815831
static const char jsonSampleWithDecimal[] =
816832
"{_id:ObjectId(\"47cc67093475061e3d95369d\"),"
817833
"query:\"kate hudson\","

src/mongo/client/internal_auth.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,14 @@ BSONObj getInternalAuthParams(size_t idx, StringData mechanism) {
127127
<< false);
128128
}
129129

130-
namespace {
131130
std::string getBSONString(const BSONObj& container, StringData field) {
132131
auto elem = container[field];
133132
uassert(ErrorCodes::BadValue,
134133
str::stream() << "Field '" << field << "' must be of type string",
135134
elem.type() == String);
136135
return elem.String();
137136
}
138-
} // namespace
137+
139138

140139
std::string getInternalAuthDB() {
141140
stdx::lock_guard<stdx::mutex> lk(internalAuthKeysMutex);

src/mongo/client/sdam/server_selection_json_test_runner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ using namespace mongo::sdam;
105105

106106
namespace mongo::sdam {
107107

108-
static std::ostream& operator<<(std::ostream& os, const std::vector<HostAndPort>& input) {
108+
std::ostream& operator<<(std::ostream& os, const std::vector<HostAndPort>& input) {
109109
for (auto const& i : input) {
110110
os << i.toString() << " ";
111111
}

src/mongo/client/sdam/topology_description_test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
namespace mongo {
5858

59-
static bool operator==(const TopologyVersion& a, const TopologyVersion& b) {
59+
bool operator==(const TopologyVersion& a, const TopologyVersion& b) {
6060
return a.getProcessId() == b.getProcessId() && a.getCounter() == b.getCounter();
6161
}
6262

src/mongo/client/streamable_replica_set_monitor.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ bool maxWireCompare(const ServerDescriptionPtr& a, const ServerDescriptionPtr& b
9393
return a->getMaxWireVersion() < b->getMaxWireVersion();
9494
}
9595

96+
bool secondaryPredicate(const ServerDescriptionPtr& server) {
97+
return server->getType() == ServerType::kRSSecondary;
98+
}
99+
96100
bool primaryOrSecondaryPredicate(const ServerDescriptionPtr& server) {
97101
const auto serverType = server->getType();
98102
return serverType == ServerType::kRSPrimary || serverType == ServerType::kRSSecondary;

src/mongo/crypto/fle_crypto.cpp

+30-4
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,13 @@ void toEncryptedBinData(StringData field,
387387
builder->appendBinData(field, buf.size(), BinDataType::Encrypt, buf.data());
388388
}
389389

390+
std::pair<EncryptedBinDataType, ConstDataRange> fromEncryptedBinData(const BSONElement element) {
391+
uassert(
392+
6672414, "Expected binData with subtype Encrypt", element.isBinData(BinDataType::Encrypt));
393+
394+
return fromEncryptedConstDataRange(binDataToCDR(element));
395+
}
396+
390397
template <FLETokenType TokenT>
391398
FLEToken<TokenT> FLETokenFromCDR(ConstDataRange cdr) {
392399
auto block = PrfBlockfromCDR(cdr);
@@ -425,6 +432,14 @@ StatusWith<std::vector<uint8_t>> encryptData(ConstDataRange key, ConstDataRange
425432
return {out};
426433
}
427434

435+
StatusWith<std::vector<uint8_t>> encryptData(ConstDataRange key, uint64_t value) {
436+
437+
std::array<char, sizeof(uint64_t)> bufValue;
438+
DataView(bufValue.data()).write<LittleEndian<uint64_t>>(value);
439+
440+
return encryptData(key, bufValue);
441+
}
442+
428443
StatusWith<std::vector<uint8_t>> decryptDataWithAssociatedData(ConstDataRange key,
429444
ConstDataRange associatedData,
430445
ConstDataRange cipherText,
@@ -1451,6 +1466,21 @@ void collectIndexedFields(std::vector<EDCIndexedFields>* pFields,
14511466
}
14521467
}
14531468

1469+
void collectFieldValidationInfo(stdx::unordered_map<std::string, ConstDataRange>* pFields,
1470+
ConstDataRange cdr,
1471+
StringData fieldPath) {
1472+
pFields->insert({fieldPath.toString(), cdr});
1473+
}
1474+
1475+
stdx::unordered_map<std::string, EncryptedField> toFieldMap(const EncryptedFieldConfig& efc) {
1476+
stdx::unordered_map<std::string, EncryptedField> fields;
1477+
for (const auto& field : efc.getFields()) {
1478+
fields.insert({field.getPath().toString(), field});
1479+
}
1480+
1481+
return fields;
1482+
}
1483+
14541484
uint64_t generateRandomContention(uint64_t cm) {
14551485
// For non-contentious fields, we select the partition number, u, to be equal to 0.
14561486
//
@@ -4171,7 +4201,6 @@ std::size_t Edges::size() const {
41714201
return (_trimFactor == 0 ? 1 : 0) + edges;
41724202
}
41734203

4174-
namespace {
41754204
template <typename T>
41764205
std::unique_ptr<Edges> getEdgesT(
41774206
T value, T min, T max, int sparsity, const boost::optional<int>& trimFactor) {
@@ -4187,7 +4216,6 @@ std::unique_ptr<Edges> getEdgesT(
41874216
std::string valueBinTrimmed = valueBin.substr(bits - maxlen, maxlen);
41884217
return std::make_unique<Edges>(valueBinTrimmed, sparsity, trimFactor);
41894218
}
4190-
} // namespace
41914219

41924220
std::unique_ptr<Edges> getEdgesInt32(int32_t value,
41934221
boost::optional<int32_t> min,
@@ -4274,7 +4302,6 @@ std::uint64_t getEdgesLength(BSONType fieldType, StringData fieldPath, QueryType
42744302
MONGO_UNREACHABLE;
42754303
}
42764304

4277-
namespace {
42784305
template <typename T>
42794306
class MinCoverGenerator {
42804307
public:
@@ -4407,7 +4434,6 @@ void adjustBounds(T& lowerBound, bool includeLowerBound, T& upperBound, bool inc
44074434
upperBound.value -= 1;
44084435
}
44094436
}
4410-
} // namespace
44114437

44124438
std::vector<std::string> minCoverInt32(int32_t lowerBound,
44134439
bool includeLowerBound,

0 commit comments

Comments
 (0)