{"id":22872,"url":"https://patchwork.libcamera.org/api/1.1/patches/22872/?format=json","web_url":"https://patchwork.libcamera.org/patch/22872/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20250225173531.2595922-3-pobrn@protonmail.com>","date":"2025-02-25T17:35:47","name":"[v4,2/8] libcamera: base: log: Use `std::from_chars()`","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"233928e1aa8ded0d428b00d420fb074d72ddf1ed","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/1.1/people/133/?format=json","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22872/mbox/","series":[{"id":5022,"url":"https://patchwork.libcamera.org/api/1.1/series/5022/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5022","date":"2025-02-25T17:35:34","name":"libcamera: base: log: Misc. changes","version":4,"mbox":"https://patchwork.libcamera.org/series/5022/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22872/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22872/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AC5F6BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Feb 2025 17:35:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 74BA56872E;\n\tTue, 25 Feb 2025 18:35:54 +0100 (CET)","from mail-10628.protonmail.ch (mail-10628.protonmail.ch\n\t[79.135.106.28])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8851268729\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Feb 2025 18:35:53 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"J7gQFGzC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1740504952; x=1740764152;\n\tbh=xKvIYnd54/uUWp7DK4M4mncZabCWFRWoHU/yRFWVl/w=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=J7gQFGzCYGeV44i4dmJQswR+KznjjzJ0mPmJgi8D1Yk4P7jOfLyszjR3hDZUJ+bbX\n\t/6L4XOi2CQAQ45axfsUuoP3jxYqa8UxhAbOCJ8A3jRWA9//GhCoUCwSrkW0cRcUVhS\n\tg798uXB0xk15kDHT8mvVLm15Qiw0N7zfTX5vFAN5USK0fmhB57/XEAq8ItOiV21RmM\n\teOiBl4LlH/XP1jqcA65z5xcYrpk8duN1ExgHk0ZXtKffp+rzLIwJId3X+1S0ZZmmBC\n\tTC4KDTEBTv3hy8Fx/jAr6xXKiWZekri/awu1b+Xzl+YFwVMMA0oj7ldt2iNCTNMWS+\n\tbhO4RwFJsnEXQ==","Date":"Tue, 25 Feb 2025 17:35:47 +0000","To":"libcamera-devel@lists.libcamera.org","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>","Subject":"[PATCH v4 2/8] libcamera: base: log: Use `std::from_chars()`","Message-ID":"<20250225173531.2595922-3-pobrn@protonmail.com>","In-Reply-To":"<20250225173531.2595922-1-pobrn@protonmail.com>","References":"<20250225173531.2595922-1-pobrn@protonmail.com>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"05ebc7f672c0c5d53f5040d859b1ce17e687f0cc","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Use the `std::from_chars()` function from `<charconv>` to\nparse the integral log level instead of `strtoul` as it\nprovides an easier to use interface and better type safety.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/libcamera/base/log.cpp | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\nindex 009f6c737..42514de97 100644\n--- a/src/libcamera/base/log.cpp\n+++ b/src/libcamera/base/log.cpp\n@@ -8,6 +8,7 @@\n #include <libcamera/base/log.h>\n \n #include <array>\n+#include <charconv>\n #include <fnmatch.h>\n #include <fstream>\n #include <iostream>\n@@ -686,12 +687,11 @@ LogSeverity Logger::parseLogLevel(const std::string &level)\n \t\t\"FATAL\",\n \t};\n \n-\tint severity;\n+\tunsigned int severity;\n \n \tif (std::isdigit(level[0])) {\n-\t\tchar *endptr;\n-\t\tseverity = strtoul(level.c_str(), &endptr, 10);\n-\t\tif (*endptr != '\\0' || severity > LogFatal)\n+\t\tauto [end, ec] = std::from_chars(level.data(), level.data() + level.size(), severity);\n+\t\tif (ec != std::errc() || *end != '\\0' || severity > LogFatal)\n \t\t\tseverity = LogInvalid;\n \t} else {\n \t\tseverity = LogInvalid;\n","prefixes":["v4","2/8"]}