diff options
author | Adam Midvidy <amidvidy@gmail.com> | 2016-01-08 16:40:23 -0500 |
---|---|---|
committer | Adam Midvidy <amidvidy@gmail.com> | 2016-01-08 17:14:38 -0500 |
commit | 4f7b4de66892c74adc0817776ec059b13678de64 (patch) | |
tree | db2b768ea52ef6202baef94952f0ae3c907e0001 | |
parent | 5d5bf5bbe97199e52b0d4ef4c212aa806d60cb45 (diff) | |
download | mongo-4f7b4de66892c74adc0817776ec059b13678de64.tar.gz |
SERVER-18373 SERVER-18219 add MONGO_UNREACHABLE macro where compiler cannot deduce that WCE retry loops will return
-rw-r--r-- | src/mongo/db/repl/minvalid.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/sync.cpp | 1 | ||||
-rw-r--r-- | src/mongo/util/assert_util.h | 14 |
3 files changed, 16 insertions, 0 deletions
diff --git a/src/mongo/db/repl/minvalid.cpp b/src/mongo/db/repl/minvalid.cpp index ec39364ea13..f358ab59d05 100644 --- a/src/mongo/db/repl/minvalid.cpp +++ b/src/mongo/db/repl/minvalid.cpp @@ -81,6 +81,7 @@ bool getInitialSyncFlag() { return false; } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(&txn, "getInitialSyncFlags", minvalidNS); + MONGO_UNREACHABLE; } void setMinValid(OperationContext* ctx, OpTime ts) { diff --git a/src/mongo/db/repl/sync.cpp b/src/mongo/db/repl/sync.cpp index d77827bc57c..85fde74d5fc 100644 --- a/src/mongo/db/repl/sync.cpp +++ b/src/mongo/db/repl/sync.cpp @@ -144,6 +144,7 @@ bool Sync::shouldRetry(OperationContext* txn, const BSONObj& o) { } } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "InsertRetry", nss.ns()); + MONGO_UNREACHABLE; } } // namespace repl diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index 4a932db33f9..abff9afcace 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -401,3 +401,17 @@ std::string demangleName(const std::type_info& typeinfo); ::mongo::logger::LogSeverity::Log()) \ << "caught unknown exception in destructor (" << __FUNCTION__ << ")" << std::endl; \ } + +/** + * The purpose of this macro is to instruct the compiler that a line of code will never be reached. + * + * Example: + * // code above checks that expr can only be FOO or BAR + * switch (expr) { + * case FOO: { ... } + * case BAR: { ... } + * default: + * MONGO_UNREACHABLE; + */ + +#define MONGO_UNREACHABLE ::mongo::invariantFailed("Hit a MONGO_UNREACHABLE!", __FILE__, __LINE__); |