summaryrefslogtreecommitdiff
path: root/src/mongo/rpc/metadata
diff options
context:
space:
mode:
authorADAM David Alan Martin <adam.martin@10gen.com>2017-06-18 23:22:02 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2017-06-18 23:46:57 -0400
commit9abef6f25aadfd04309cb2219068097f93dc961d (patch)
treef88c7f183f201813f363d5d68c1a4a76781ca7ef /src/mongo/rpc/metadata
parenta5f0a84c79b6ce41fef33da920c62be0ecc8f07b (diff)
downloadmongo-9abef6f25aadfd04309cb2219068097f93dc961d.tar.gz
SERVER-27244 Status usage compile-time facilities.
There are numerous places in the codebase where `mongo::Status` or `mongo::StatusWith< T >` objects are returned and never checked. Many of these are innocuous, but many of them are potentially severe bugs. This change introduces facilities to permit compile-time warning of unchecked `Status` and `StatusWith` usage on clang compilers. It introduces an `ignore` function which is useful to state that a specific "ignored status" case was intentional. It not presently an error, in clang builds, to forget to check a `Status` -- this will come in a later commit. This also introduces a `transitional_ignore` function, which allows for easy continual auditing of the codebase for current "whitelisted" unchecked-status instances. All present "ignored status" cases have been marked `transitional_ignore`.
Diffstat (limited to 'src/mongo/rpc/metadata')
-rw-r--r--src/mongo/rpc/metadata/oplog_query_metadata_test.cpp4
-rw-r--r--src/mongo/rpc/metadata/repl_set_metadata_test.cpp4
-rw-r--r--src/mongo/rpc/metadata/sharding_metadata.cpp4
3 files changed, 6 insertions, 6 deletions
diff --git a/src/mongo/rpc/metadata/oplog_query_metadata_test.cpp b/src/mongo/rpc/metadata/oplog_query_metadata_test.cpp
index cc08bf832fb..06784a65ee1 100644
--- a/src/mongo/rpc/metadata/oplog_query_metadata_test.cpp
+++ b/src/mongo/rpc/metadata/oplog_query_metadata_test.cpp
@@ -47,7 +47,7 @@ TEST(ReplResponseMetadataTest, OplogQueryMetadataRoundtrip) {
ASSERT_EQ(opTime2, metadata.getLastOpApplied());
BSONObjBuilder builder;
- metadata.writeToMetadata(&builder);
+ metadata.writeToMetadata(&builder).transitional_ignore();
BSONObj expectedObj(BSON(kOplogQueryMetadataFieldName << BSON(
"lastOpCommitted"
@@ -75,7 +75,7 @@ TEST(ReplResponseMetadataTest, OplogQueryMetadataRoundtrip) {
ASSERT_EQ(metadata.getSyncSourceIndex(), clonedMetadata.getSyncSourceIndex());
BSONObjBuilder clonedBuilder;
- clonedMetadata.writeToMetadata(&clonedBuilder);
+ clonedMetadata.writeToMetadata(&clonedBuilder).transitional_ignore();
BSONObj clonedSerializedObj = clonedBuilder.obj();
ASSERT_BSONOBJ_EQ(expectedObj, clonedSerializedObj);
diff --git a/src/mongo/rpc/metadata/repl_set_metadata_test.cpp b/src/mongo/rpc/metadata/repl_set_metadata_test.cpp
index 6d5b7be1a2f..b6285e63342 100644
--- a/src/mongo/rpc/metadata/repl_set_metadata_test.cpp
+++ b/src/mongo/rpc/metadata/repl_set_metadata_test.cpp
@@ -52,7 +52,7 @@ TEST(ReplResponseMetadataTest, Roundtrip) {
ASSERT_TRUE(metadata.hasReplicaSetId());
BSONObjBuilder builder;
- metadata.writeToMetadata(&builder);
+ metadata.writeToMetadata(&builder).transitional_ignore();
BSONObj expectedObj(
BSON(kReplSetMetadataFieldName
@@ -82,7 +82,7 @@ TEST(ReplResponseMetadataTest, Roundtrip) {
ASSERT_EQ(metadata.getReplicaSetId(), clonedMetadata.getReplicaSetId());
BSONObjBuilder clonedBuilder;
- clonedMetadata.writeToMetadata(&clonedBuilder);
+ clonedMetadata.writeToMetadata(&clonedBuilder).transitional_ignore();
BSONObj clonedSerializedObj = clonedBuilder.obj();
ASSERT_BSONOBJ_EQ(expectedObj, clonedSerializedObj);
diff --git a/src/mongo/rpc/metadata/sharding_metadata.cpp b/src/mongo/rpc/metadata/sharding_metadata.cpp
index b1c4b47b8e5..384c75f2679 100644
--- a/src/mongo/rpc/metadata/sharding_metadata.cpp
+++ b/src/mongo/rpc/metadata/sharding_metadata.cpp
@@ -116,7 +116,7 @@ Status ShardingMetadata::downconvert(const BSONObj& commandReply,
// We can reuse the same logic to write the sharding metadata out to the legacy
// command as the element has the same format whether it is there or on the metadata
// object.
- swShardingMetadata.getValue().writeToMetadata(legacyCommandReplyBob);
+ swShardingMetadata.getValue().writeToMetadata(legacyCommandReplyBob).transitional_ignore();
} else if (swShardingMetadata.getStatus() == ErrorCodes::NoSuchKey) {
// It is valid to not have a $gleStats field.
} else {
@@ -132,7 +132,7 @@ Status ShardingMetadata::upconvert(const BSONObj& legacyCommand,
// as it has the same format whether it is there or on the metadata object.
auto swShardingMetadata = readFromMetadata(legacyCommand);
if (swShardingMetadata.isOK()) {
- swShardingMetadata.getValue().writeToMetadata(metadataBob);
+ swShardingMetadata.getValue().writeToMetadata(metadataBob).transitional_ignore();
// Write out the command excluding the $gleStats subobject.
for (const auto& elem : legacyCommand) {