From af0d21ef8113e6bc2e18c28781f409741a977e3e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 26 Apr 2019 17:34:44 +0300 Subject: libcamera: log: Add a LogInvalid entry to LogSeverity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit enum LogSeverity values are assigned or compared to -1 to flag invalid log severities. This generates compilation warnings with clang. Fix it by adding an explicit LogInvalid entry to the enumeration. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Kieran Bingham --- src/libcamera/log.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/libcamera/log.cpp') diff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp index ebf55330..0ba276e5 100644 --- a/src/libcamera/log.cpp +++ b/src/libcamera/log.cpp @@ -174,7 +174,7 @@ void Logger::parseLogLevels() continue; LogSeverity severity = parseLogLevel(level); - if (severity == -1) + if (severity == LogInvalid) continue; levels_.push_back({ category, severity }); @@ -189,7 +189,7 @@ void Logger::parseLogLevels() * LogFatal, or as a string corresponding to the severity name in uppercase. Any * other value is invalid. * - * \return The log severity, or -1 if the string is invalid + * \return The log severity, or LogInvalid if the string is invalid */ LogSeverity Logger::parseLogLevel(const std::string &level) { @@ -207,9 +207,9 @@ LogSeverity Logger::parseLogLevel(const std::string &level) char *endptr; severity = strtoul(level.c_str(), &endptr, 10); if (*endptr != '\0' || severity > LogFatal) - severity = -1; + severity = LogInvalid; } else { - severity = -1; + severity = LogInvalid; for (unsigned int i = 0; i < ARRAY_SIZE(names); ++i) { if (names[i] == level) { severity = i; @@ -416,13 +416,13 @@ LogMessage::LogMessage(const char *fileName, unsigned int line, * on the compiler type and version, and optimization level, the move * constructor is defined even if it will likely never be called, and ensures * that the destructor of the \a other message will not output anything to the - * log by setting the severity to -1. + * log by setting the severity to LogInvalid. */ LogMessage::LogMessage(LogMessage &&other) : msgStream_(std::move(other.msgStream_)), category_(other.category_), severity_(other.severity_) { - other.severity_ = static_cast(-1); + other.severity_ = LogInvalid; } void LogMessage::init(const char *fileName, unsigned int line) @@ -445,7 +445,7 @@ void LogMessage::init(const char *fileName, unsigned int line) LogMessage::~LogMessage() { /* Don't print anything if we have been moved to another LogMessage. */ - if (severity_ == -1) + if (severity_ == LogInvalid) return; msgStream_ << std::endl; -- cgit v1.2.1