From patchwork Thu Jun 12 13:56:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 23626 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6B86ABDE6B for ; Mon, 23 Jun 2025 14:13:08 +0000 (UTC) Received: from pendragon.ideasonboard.com (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B5C6A15BF for ; Mon, 23 Jun 2025 16:12:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750687971; bh=ggINKzTg3FDnoDSN/3GUf8CvotH316eNtWQv2r5Xp6c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Resent-From:Resent-To:From; b=hVXWgn6PYGLre7AlPD+myutL3jYZj9sEImLiiVCcCybqAY6XQioJqsrsfpYCD1cUb 5pamSBFJQOXnZfdUGkFwIro/b7Eq8kUsTfH0MwDHUfIDjyRB8NH5hEjy3urNcOvrV2 8b3Z4TXmlXXWrgGbX1mmmorgczDZLl+nElFJv3O8= Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id EI1mAVrdSmgXMi0A4E0KoQ (envelope-from ) for ; Thu, 12 Jun 2025 15:59:54 +0200 Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by perceval.ideasonboard.com (Postfix) with ESMTPS id D0523169; Thu, 12 Jun 2025 15:59:53 +0200 (CEST) Authentication-Results: perceval.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.a=rsa-sha256 header.s=mail header.b=GROky4fD; dkim-atps=neutral Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 46E5968DC4; Thu, 12 Jun 2025 16:00:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="GROky4fD"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 59FEC68DBD for ; Thu, 12 Jun 2025 15:59:56 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:3176:2bf8:8f04:4c4]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 965087E4; Thu, 12 Jun 2025 15:59:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1749736787; bh=4HmJZGXC2e+pWBGyuZ0aJO0K3h6qnix/CcEQXp7Q3E4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GROky4fDjKriSewZCMruBI+gRs2wRMS83OKoi6J3FBlskqMfxRAGhlRO3EAtxsDh/ tZgrP5ls0r2h+7KixUK6RhKKW57T1fp5/43uCXy6AhJaovAVGqzaYwtTfv0Nf4Zjan tMHIJCZrspRlGDoKDMQ4Ya4aLGABgyMwx/mSh3SU= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug , =?utf-8?q?Barnab=C3=A1s_P?= =?utf-8?b?xZFjemU=?= Subject: [PATCH v2 2/2] libcamera: base: Fix log level parsing when multiple categories are listed Date: Thu, 12 Jun 2025 15:56:45 +0200 Message-ID: <20250612135943.522819-3-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250612135943.522819-1-stefan.klug@ideasonboard.com> References: <20250612135943.522819-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" X-TUID: 9hU+iZnFcW/b Resent-From: Kieran Bingham Resent-To: parsemail@patchwork.libcamera.org For a list of log levels like LIBCAMERA_LOG_LEVELS="CatA:0,CatB:1" only the severity of the last entry is correctly parsed. Due to the change of level to a string_view in 24c2caa1c1b3 ("libcamera: base: log: Use `std::string_view` to avoid some copies") the level is no longer necessarily null terminated as it is a view on the original data. Replace the check for a terminating null by a check for the end position to fix the issue. Fixes: 24c2caa1c1b3 ("libcamera: base: log: Use `std::string_view` to avoid some copies") Signed-off-by: Stefan Klug Reviewed-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- src/libcamera/base/log.cpp | 5 +++-- test/log/meson.build | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcamera/base/log.cpp b/src/libcamera/base/log.cpp index 8bf3e1daa9c6..6a8e2a3eb844 100644 --- a/src/libcamera/base/log.cpp +++ b/src/libcamera/base/log.cpp @@ -690,8 +690,9 @@ LogSeverity Logger::parseLogLevel(std::string_view level) unsigned int severity = LogInvalid; if (std::isdigit(level[0])) { - auto [end, ec] = std::from_chars(level.data(), level.data() + level.size(), severity); - if (ec != std::errc() || *end != '\0' || severity > LogFatal) + const char *levelEnd = level.data() + level.size(); + auto [end, ec] = std::from_chars(level.data(), levelEnd, severity); + if (ec != std::errc() || end != levelEnd || severity > LogFatal) severity = LogInvalid; } else { for (unsigned int i = 0; i < std::size(names); ++i) { diff --git a/test/log/meson.build b/test/log/meson.build index d91f62b9ea5b..f413c3898b2d 100644 --- a/test/log/meson.build +++ b/test/log/meson.build @@ -1,7 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 log_test = [ - {'name': 'log_api', 'sources': ['log_api.cpp'], 'should_fail':true}, + {'name': 'log_api', 'sources': ['log_api.cpp']}, {'name': 'log_process', 'sources': ['log_process.cpp']}, ]