From patchwork Fri Jul 12 05:29:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 20651 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5EF16BDB1C for ; Fri, 12 Jul 2024 05:29:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E3F046337A; Fri, 12 Jul 2024 07:29:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J2sYmYg/"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81B3C6336E for ; Fri, 12 Jul 2024 07:29:36 +0200 (CEST) Received: from localhost.localdomain (unknown [IPv6:2405:201:2015:f873:55f8:639e:8e9f:12ec]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C3BAD50; Fri, 12 Jul 2024 07:29:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1720762142; bh=qMn3R1HdkGQNP0A9FbcXQQtgNYGG5yOo3ZcJfdSZ0jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2sYmYg/qIT9NetQ1hMTFoGT/BHopoH881jCO/++O1r7yk6ccae0kxV1pkIWthM/W pDLkXP60M8A3f2doSDaxBpqPDOiA4Y7IDi612iiGZ205tdWolxN3WYYXlMy0ICsVgY MwNDuw7EzMCcbymWr+e7SxVVcQTKJTHnMdhlIUTk= From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Xavier Roumegue , Umang Jain Subject: [RFC PATCH 3/6] libcamera: yaml_parser: Increase sentinel to 100k Date: Fri, 12 Jul 2024 10:59:17 +0530 Message-ID: <20240712052920.33396-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240712052920.33396-1-umang.jain@ideasonboard.com> References: <20240712052920.33396-1-umang.jain@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" From: Xavier Roumegue Instead of manually increasing the limit, prepare a constexpr for maximum sentinel and use that instead. Signed-off-by: Xavier Roumegue Signed-off-by: Umang Jain --- src/libcamera/yaml_parser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp index 025006bc..09ed75f1 100644 --- a/src/libcamera/yaml_parser.cpp +++ b/src/libcamera/yaml_parser.cpp @@ -690,6 +690,8 @@ void YamlParserContext::readValue(std::string &value, EventPtr event) int YamlParserContext::parseDictionaryOrList(YamlObject::Type type, const std::function &parseItem) { + constexpr unsigned int maxSentinel = 100000; + yaml_event_type_t endEventType = YAML_SEQUENCE_END_EVENT; if (type == YamlObject::Type::Dictionary) endEventType = YAML_MAPPING_END_EVENT; @@ -698,7 +700,7 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type, * Add a safety counter to make sure we don't loop indefinitely in case * the YAML file is malformed. */ - for (unsigned int sentinel = 2000; sentinel; sentinel--) { + for (unsigned int sentinel = maxSentinel; sentinel; sentinel--) { auto evt = nextEvent(); if (!evt) return -EINVAL; @@ -711,8 +713,9 @@ int YamlParserContext::parseDictionaryOrList(YamlObject::Type type, return ret; } - LOG(YamlParser, Error) << "The YAML file contains a List or Dictionary" - " whose size exceeds the parser's limit (1000)"; + LOG(YamlParser, Error) + << "The YAML file contains a List or Dictionary whose size exceeds" + << " the parser's limit (" << maxSentinel << ")"; return -EINVAL; }