[{"id":34608,"web_url":"https://patchwork.libcamera.org/comment/34608/","msgid":"<20250612141055.GA10542@pendragon.ideasonboard.com>","date":"2025-06-12T14:10:55","subject":"Re: [PATCH v2 2/2] libcamera: base: Fix log level parsing when\n\tmultiple categories are listed","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jun 12, 2025 at 03:56:45PM +0200, Stefan Klug wrote:\n> For a list of log levels like LIBCAMERA_LOG_LEVELS=\"CatA:0,CatB:1\" only\n> the severity of the last entry is correctly parsed.\n> \n> Due to the change of level to a string_view in 24c2caa1c1b3 (\"libcamera:\n> base: log: Use `std::string_view` to avoid some copies\") the level is no\n> longer necessarily null terminated as it is a view on the original data.\n> \n> Replace the check for a terminating null by a check for the end position\n> to fix the issue.\n> \n> Fixes: 24c2caa1c1b3 (\"libcamera: base: log: Use `std::string_view` to avoid some copies\")\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/base/log.cpp | 5 +++--\n>  test/log/meson.build       | 2 +-\n>  2 files changed, 4 insertions(+), 3 deletions(-)\n> \n> diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp\n> index 8bf3e1daa9c6..6a8e2a3eb844 100644\n> --- a/src/libcamera/base/log.cpp\n> +++ b/src/libcamera/base/log.cpp\n> @@ -690,8 +690,9 @@ LogSeverity Logger::parseLogLevel(std::string_view level)\n>  \tunsigned int severity = LogInvalid;\n>  \n>  \tif (std::isdigit(level[0])) {\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\tconst char *levelEnd = level.data() + level.size();\n> +\t\tauto [end, ec] = std::from_chars(level.data(), levelEnd, severity);\n> +\t\tif (ec != std::errc() || end != levelEnd || severity > LogFatal)\n>  \t\t\tseverity = LogInvalid;\n>  \t} else {\n>  \t\tfor (unsigned int i = 0; i < std::size(names); ++i) {\n> diff --git a/test/log/meson.build b/test/log/meson.build\n> index d91f62b9ea5b..f413c3898b2d 100644\n> --- a/test/log/meson.build\n> +++ b/test/log/meson.build\n> @@ -1,7 +1,7 @@\n>  # SPDX-License-Identifier: CC0-1.0\n>  \n>  log_test = [\n> -    {'name': 'log_api', 'sources': ['log_api.cpp'], 'should_fail':true},\n> +    {'name': 'log_api', 'sources': ['log_api.cpp']},\n>      {'name': 'log_process', 'sources': ['log_process.cpp']},\n>  ]\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":["parsemail@patchwork.libcamera.org","kbingham@ideasonboard.com"],"Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0A198BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 14:13:16 +0000 (UTC)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net\n\t[86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 57BEC15BF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 16:12:59 +0200 (CEST)","from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id YIQDLPjfSmgCPC0A4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 12 Jun 2025 16:11:04 +0200","from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\tby perceval.ideasonboard.com (Postfix) with ESMTPS\n\tid 64DE37E4;\tThu, 12 Jun 2025 16:11:04 +0200 (CEST)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5C5BC68DC0;\n\tThu, 12 Jun 2025 16:11:11 +0200 (CEST)","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 8784C6154C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jun 2025 16:11:09 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 764B1D6;\n\tThu, 12 Jun 2025 16:11:00 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750687979;\n\tbh=FtAKVPa68jV3qLO72uV5lQVmqwu/fWTgg+SFJ1JcugA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:List-Id:\n\tList-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\tResent-From:Resent-To:From;\n\tb=q9xSewExu8SCI37tHC5Rej2pPjOaNHK0OX4/lCx1npUxJVKKfgWNCOSPcn83CdW1G\n\tDwY6wpYW3HiA40NNarFgHU0kH1kuIly5jNqipPiluXCzk59JqQJnIyfW9Cd+yLMUIN\n\tvYAgeFPmS3OQD8x5/O78DwIcxdmb+BPktiPXcRus=","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749737460;\n\tbh=WtyH/wO2PN8f1FUqDaShAqFU88t3mYUg20Zfz3SMgx0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=LNRernnJumOvOoKdjrSdHMcrTvNxzCOyMOnwzldQj8yNlGh2Z6eJQWccA3cfNSfB9\n\tJ+UdRp5LYcOx+ETBne5Vlc/e43mcVMybhPbXcGwCL4zyWTLy9uXKnKr7TimkL6ZCaq\n\tkohkrGM0KZcxPgnnzGT76D2PL545Yrv8mfUvrszc="],"Authentication-Results":["perceval.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.a=rsa-sha256 header.s=mail header.b=LNRernnJ; dkim-atps=neutral","lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"LNRernnJ\";\tdkim-atps=neutral"],"Date":"Thu, 12 Jun 2025 17:10:55 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, =?utf-8?b?QmFybmFiw6FzIFDFkWN6?=\n\t=?utf-8?q?e?= <barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v2 2/2] libcamera: base: Fix log level parsing when\n\tmultiple categories are listed","Message-ID":"<20250612141055.GA10542@pendragon.ideasonboard.com>","References":"<20250612135943.522819-1-stefan.klug@ideasonboard.com>\n\t<20250612135943.522819-3-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Disposition":"inline","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250612135943.522819-3-stefan.klug@ideasonboard.com>","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>","X-TUID":"3sHMvt0XYoNA","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"}}]