diff options
author | ADAM David Alan Martin <adam.martin@10gen.com> | 2017-06-18 23:22:02 -0400 |
---|---|---|
committer | ADAM David Alan Martin <adam.martin@10gen.com> | 2017-06-18 23:46:57 -0400 |
commit | 9abef6f25aadfd04309cb2219068097f93dc961d (patch) | |
tree | f88c7f183f201813f363d5d68c1a4a76781ca7ef /src/mongo/logger | |
parent | a5f0a84c79b6ce41fef33da920c62be0ecc8f07b (diff) | |
download | mongo-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/logger')
-rw-r--r-- | src/mongo/logger/log_test.cpp | 9 | ||||
-rw-r--r-- | src/mongo/logger/logstream_builder.cpp | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/mongo/logger/log_test.cpp b/src/mongo/logger/log_test.cpp index 5be29f5d74b..122820f0fef 100644 --- a/src/mongo/logger/log_test.cpp +++ b/src/mongo/logger/log_test.cpp @@ -91,17 +91,20 @@ TEST_F(LogTestUnadornedEncoder, DetachAppender) { MessageLogDomain domain; // Appending to the domain before attaching the appender does not affect the appender. - domain.append(MessageEventEphemeral(Date_t(), LogSeverity::Log(), "", "1")); + domain.append(MessageEventEphemeral(Date_t(), LogSeverity::Log(), "", "1")) + .transitional_ignore(); ASSERT_EQUALS(0, dynamic_cast<CountAppender*>(countAppender.get())->getCount()); // Appending to the domain after attaching the appender does affect the appender. MessageLogDomain::AppenderHandle handle = domain.attachAppender(std::move(countAppender)); - domain.append(MessageEventEphemeral(Date_t(), LogSeverity::Log(), "", "2")); + domain.append(MessageEventEphemeral(Date_t(), LogSeverity::Log(), "", "2")) + .transitional_ignore(); countAppender = domain.detachAppender(handle); ASSERT_EQUALS(1, dynamic_cast<CountAppender*>(countAppender.get())->getCount()); // Appending to the domain after detaching the appender does not affect the appender. - domain.append(MessageEventEphemeral(Date_t(), LogSeverity::Log(), "", "3")); + domain.append(MessageEventEphemeral(Date_t(), LogSeverity::Log(), "", "3")) + .transitional_ignore(); ASSERT_EQUALS(1, dynamic_cast<CountAppender*>(countAppender.get())->getCount()); } diff --git a/src/mongo/logger/logstream_builder.cpp b/src/mongo/logger/logstream_builder.cpp index 2378558bd4a..f0dfbaeebe9 100644 --- a/src/mongo/logger/logstream_builder.cpp +++ b/src/mongo/logger/logstream_builder.cpp @@ -104,7 +104,7 @@ LogstreamBuilder::~LogstreamBuilder() { MessageEventEphemeral message( Date_t::now(), _severity, _component, _contextName, _baseMessage); message.setIsTruncatable(_isTruncatable); - _domain->append(message); + _domain->append(message).transitional_ignore(); if (_tee) { _os->str(""); logger::MessageEventDetailsEncoder teeEncoder; |