{"id":1109,"url":"https://patchwork.libcamera.org/api/patches/1109/?format=json","web_url":"https://patchwork.libcamera.org/patch/1109/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190426150155.18652-4-laurent.pinchart@ideasonboard.com>","date":"2019-04-26T15:01:50","name":"[libcamera-devel,3/8] libcamera: log: Add a LogInvalid entry to LogSeverity","commit_ref":"af0d21ef8113e6bc2e18c28781f409741a977e3e","pull_url":null,"state":"accepted","archived":false,"hash":"3ec0af34ad9c3ed27be1704d50b6f06100b79019","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1109/mbox/","series":[{"id":271,"url":"https://patchwork.libcamera.org/api/series/271/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=271","date":"2019-04-26T15:01:47","name":"Fix clang compilation warnings and errors","version":1,"mbox":"https://patchwork.libcamera.org/series/271/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1109/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1109/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4AE5060E9D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Apr 2019 17:02:10 +0200 (CEST)","from pendragon.station (net-37-182-44-227.cust.vodafonedsl.it\n\t[37.182.44.227])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DAE845F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Apr 2019 17:02:09 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556290930;\n\tbh=CWhpKrRm0/rXUC2F3qc0D6NMeUmhc48wGmzSSiqj2ek=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Ze+tjT7B9boZqaTHk/havQubzbSrjzptxkx8AF2/XPBCmW/S7pdKJLNlJKkNelU2O\n\t0s657hV20pSI7sGZm5HGLQro53OVOgPl2uohYyfsz7HVNCcWbIS0qX3HVY71M6bqhN\n\tw0UTEVIWs8TdfRZfO77AxfFCL6J8tRdUIOlt8fHg=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 26 Apr 2019 18:01:50 +0300","Message-Id":"<20190426150155.18652-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190426150155.18652-1-laurent.pinchart@ideasonboard.com>","References":"<20190426150155.18652-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 3/8] libcamera: log: Add a LogInvalid\n\tentry to LogSeverity","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 26 Apr 2019 15:02:10 -0000"},"content":"enum LogSeverity values are assigned or compared to -1 to flag invalid\nlog severities. This generates compilation warnings with clang. Fix it\nby adding an explicit LogInvalid entry to the enumeration.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/include/log.h |  3 ++-\n src/libcamera/log.cpp       | 14 +++++++-------\n 2 files changed, 9 insertions(+), 8 deletions(-)","diff":"diff --git a/src/libcamera/include/log.h b/src/libcamera/include/log.h\nindex 35a6fc105448..802836d23bf2 100644\n--- a/src/libcamera/include/log.h\n+++ b/src/libcamera/include/log.h\n@@ -12,7 +12,8 @@\n namespace libcamera {\n \n enum LogSeverity {\n-\tLogDebug,\n+\tLogInvalid = -1,\n+\tLogDebug = 0,\n \tLogInfo,\n \tLogWarning,\n \tLogError,\ndiff --git a/src/libcamera/log.cpp b/src/libcamera/log.cpp\nindex ebf553300f5b..0ba276e5707f 100644\n--- a/src/libcamera/log.cpp\n+++ b/src/libcamera/log.cpp\n@@ -174,7 +174,7 @@ void Logger::parseLogLevels()\n \t\t\tcontinue;\n \n \t\tLogSeverity severity = parseLogLevel(level);\n-\t\tif (severity == -1)\n+\t\tif (severity == LogInvalid)\n \t\t\tcontinue;\n \n \t\tlevels_.push_back({ category, severity });\n@@ -189,7 +189,7 @@ void Logger::parseLogLevels()\n  * LogFatal, or as a string corresponding to the severity name in uppercase. Any\n  * other value is invalid.\n  *\n- * \\return The log severity, or -1 if the string is invalid\n+ * \\return The log severity, or LogInvalid if the string is invalid\n  */\n LogSeverity Logger::parseLogLevel(const std::string &level)\n {\n@@ -207,9 +207,9 @@ LogSeverity Logger::parseLogLevel(const std::string &level)\n \t\tchar *endptr;\n \t\tseverity = strtoul(level.c_str(), &endptr, 10);\n \t\tif (*endptr != '\\0' || severity > LogFatal)\n-\t\t\tseverity = -1;\n+\t\t\tseverity = LogInvalid;\n \t} else {\n-\t\tseverity = -1;\n+\t\tseverity = LogInvalid;\n \t\tfor (unsigned int i = 0; i < ARRAY_SIZE(names); ++i) {\n \t\t\tif (names[i] == level) {\n \t\t\t\tseverity = i;\n@@ -416,13 +416,13 @@ LogMessage::LogMessage(const char *fileName, unsigned int line,\n  * on the compiler type and version, and optimization level, the move\n  * constructor is defined even if it will likely never be called, and ensures\n  * that the destructor of the \\a other message will not output anything to the\n- * log by setting the severity to -1.\n+ * log by setting the severity to LogInvalid.\n  */\n LogMessage::LogMessage(LogMessage &&other)\n \t: msgStream_(std::move(other.msgStream_)), category_(other.category_),\n \t  severity_(other.severity_)\n {\n-\tother.severity_ = static_cast<LogSeverity>(-1);\n+\tother.severity_ = LogInvalid;\n }\n \n void LogMessage::init(const char *fileName, unsigned int line)\n@@ -445,7 +445,7 @@ void LogMessage::init(const char *fileName, unsigned int line)\n LogMessage::~LogMessage()\n {\n \t/* Don't print anything if we have been moved to another LogMessage. */\n-\tif (severity_ == -1)\n+\tif (severity_ == LogInvalid)\n \t\treturn;\n \n \tmsgStream_ << std::endl;\n","prefixes":["libcamera-devel","3/8"]}