From patchwork Mon Dec 2 13:34:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 22150 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 37962C3295 for ; Mon, 2 Dec 2024 13:34:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DECB066080; Mon, 2 Dec 2024 14:34:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="uZH4RpWY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58B056605F for ; Mon, 2 Dec 2024 14:34:12 +0100 (CET) Received: from ideasonboard.com (mob-5-90-236-68.net.vodafone.it [5.90.236.68]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 88ED5514; Mon, 2 Dec 2024 14:33:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733146425; bh=ps1AvkkE4aqDTfJCOam9fPZFGvmUB027lVxleBkIzNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uZH4RpWYaQ4/ryNdpeQcpFM+CHSU9/napxKHn36IGo3+oafyhMmmaKaOcEKmUZH2q B692WrOgGSjxgjm9BOcWICblRlkwI7De/kiYUcyrUPIDx0w9i2kXUxlkuv6UOszzqv Cr47H63jsy8uZknXgQr07xmd9wub/V8CJKOTcT+k= From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi Subject: [PATCH v2 4/4] [DNI] libcamera: pipeline_handler: Break the Yaml Emitter Date: Mon, 2 Dec 2024 14:34:03 +0100 Message-ID: <20241202133404.41431-5-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241202133404.41431-1-jacopo.mondi@ideasonboard.com> References: <20241202133404.41431-1-jacopo.mondi@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" Break the pipeline handler with an invalid API usage sequence in pipeline_handler.cpp ASSERT() for the presence of a valid parent_ reference in the YamlOutput class hierarcy to trigger a visible error to users. FATAL default yaml_emitter.cpp:578 assertion "parent_" failed in dict() Backtrace: libcamera::YamlList::dict()+0xb4 (../src/libcamera/yaml_emitter.cpp:580) Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline_handler.cpp | 1 + src/libcamera/yaml_emitter.cpp | 42 +++++------------------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index e1ff6e6a5ce9..963a98e15894 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -818,6 +818,7 @@ void PipelineHandler::dumpConfiguration(const std::set &streams, /* \todo Dump Sensor configuration */ YamlList streamsList = configurationDict.list("streams"); + YamlList thatsanono = configurationDict.list("shouldntbehere"); for (const auto &stream : streams) { const StreamConfiguration &streamConfig = stream->configuration(); diff --git a/src/libcamera/yaml_emitter.cpp b/src/libcamera/yaml_emitter.cpp index c0629e249c57..ed0367717e11 100644 --- a/src/libcamera/yaml_emitter.cpp +++ b/src/libcamera/yaml_emitter.cpp @@ -561,12 +561,7 @@ YamlList::~YamlList() */ YamlList YamlList::list() { - if (!parent_) { - LOG(YamlEmitter, Error) - << "Invalid usage of the YamlEmitter API. " - << " The YAML output might not be correct."; - return {}; - } + ASSERT(parent_); int ret = emitSequenceStart(); if (ret) @@ -580,12 +575,7 @@ YamlList YamlList::list() */ YamlDict YamlList::dict() { - if (!parent_) { - LOG(YamlEmitter, Error) - << "Invalid usage of the YamlEmitter API. " - << " The YAML output might not be correct."; - return {}; - } + ASSERT(parent_); int ret = emitMappingStart(); if (ret) @@ -600,12 +590,7 @@ YamlDict YamlList::dict() */ void YamlList::scalar(std::string_view scalar) { - if (!parent_) { - LOG(YamlEmitter, Error) - << "Invalid usage of the YamlEmitter API. " - << " The YAML output might not be correct."; - return; - } + ASSERT(parent_); emitScalar(scalar); } @@ -652,12 +637,7 @@ YamlDict::~YamlDict() */ YamlList YamlDict::list(std::string_view key) { - if (!parent_) { - LOG(YamlEmitter, Error) - << "Invalid usage of the YamlEmitter API. " - << " The YAML output might not be correct."; - return {}; - } + ASSERT(parent_); int ret = emitScalar(key); if (ret) @@ -677,12 +657,7 @@ YamlList YamlDict::list(std::string_view key) */ YamlDict YamlDict::dict(std::string_view key) { - if (!parent_) { - LOG(YamlEmitter, Error) - << "Invalid usage of the YamlEmitter API. " - << " The YAML output might not be correct."; - return {}; - } + ASSERT(parent_); int ret = emitScalar(key); if (ret) @@ -702,12 +677,7 @@ YamlDict YamlDict::dict(std::string_view key) */ void YamlDict::scalar(std::string_view key, std::string_view scalar) { - if (!parent_) { - LOG(YamlEmitter, Error) - << "Invalid usage of the YamlEmitter API. " - << " The YAML output might not be correct."; - return; - } + ASSERT(parent_); int ret = emitScalar(key); if (ret)