Merge "base: Avoid compilation error when compiled with -Wdangling-else."

am: 80b1b18

* commit '80b1b188281b0c89e94cd9c3c3f2b04f007d6b28':
  base: Avoid compilation error when compiled with -Wdangling-else.
This commit is contained in:
Yabin Cui 2016-03-22 01:57:56 +00:00 committed by android-build-merger
commit 152b5408b1
1 changed files with 13 additions and 19 deletions

View File

@ -100,9 +100,9 @@ class ErrnoRestorer {
errno = saved_errno_;
}
// Allow this object to evaluate to false which is useful in macros.
// Allow this object to be used as part of && operation.
operator bool() const {
return false;
return true;
}
private:
@ -123,13 +123,11 @@ class ErrnoRestorer {
// else statement after LOG() macro, it won't bind to the if statement in the macro.
// do-while(0) statement doesn't work here. Because we need to support << operator
// following the macro, like "LOG(DEBUG) << xxx;".
#define LOG_TO(dest, severity) \
if (LIKELY(::android::base::severity < ::android::base::GetMinimumLogSeverity())) \
; \
else \
::android::base::ErrnoRestorer() ? *(std::ostream*)nullptr : \
::android::base::LogMessage(__FILE__, __LINE__, \
::android::base::dest, \
#define LOG_TO(dest, severity) \
UNLIKELY(::android::base::severity >= ::android::base::GetMinimumLogSeverity()) && \
::android::base::ErrnoRestorer() && \
::android::base::LogMessage(__FILE__, __LINE__, \
::android::base::dest, \
::android::base::severity, -1).stream()
// A variant of LOG that also logs the current errno value. To be used when
@ -137,13 +135,11 @@ class ErrnoRestorer {
#define PLOG(severity) PLOG_TO(DEFAULT, severity)
// Behaves like PLOG, but logs to the specified log ID.
#define PLOG_TO(dest, severity) \
if (LIKELY(::android::base::severity < ::android::base::GetMinimumLogSeverity())) \
; \
else \
::android::base::ErrnoRestorer() ? *(std::ostream*)nullptr : \
::android::base::LogMessage(__FILE__, __LINE__, \
::android::base::dest, \
#define PLOG_TO(dest, severity) \
UNLIKELY(::android::base::severity >= ::android::base::GetMinimumLogSeverity()) && \
::android::base::ErrnoRestorer() && \
::android::base::LogMessage(__FILE__, __LINE__, \
::android::base::dest, \
::android::base::severity, errno).stream()
// Marker that code is yet to be implemented.
@ -165,9 +161,7 @@ class ErrnoRestorer {
// CHECK(false == true) results in a log message of
// "Check failed: false == true".
#define CHECK(x) \
if (LIKELY((x))) \
; \
else \
LIKELY((x)) || \
ABORT_AFTER_LOG_FATAL \
::android::base::LogMessage(__FILE__, __LINE__, ::android::base::DEFAULT, \
::android::base::FATAL, -1).stream() \