summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-26 17:34:44 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-04-26 19:25:05 +0300
commitaf0d21ef8113e6bc2e18c28781f409741a977e3e (patch)
tree2685f0863955f61c5c09864cdc3c03820741b243 /src
parent2eeb826f3fa294f4f980e3a62da4e96095355997 (diff)
libcamera: log: Add a LogInvalid entry to LogSeverity
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/include/log.h3
-rw-r--r--src/libcamera/log.cpp14
2 files changed, 9 insertions, 8 deletions
diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h
index 35a6fc10..802836d2 100644
--- a/src/libcamera/include/log.h
+++ b/src/libcamera/include/log.h
@@ -12,7 +12,8 @@
namespace libcamera {
enum LogSeverity {
- LogDebug,
+ LogInvalid = -1,
+ LogDebug = 0,
LogInfo,
LogWarning,
LogError,
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<LogSeverity>(-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;