From patchwork Wed Dec 4 11:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 22160 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 75A49BDB13 for ; Wed, 4 Dec 2024 11:10:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F610618B5; Wed, 4 Dec 2024 12:10:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Riu9pgtW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B7D9F618B5 for ; Wed, 4 Dec 2024 12:10:21 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:9f48:37c3:24be:426d]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9FB6FB2B; Wed, 4 Dec 2024 12:09:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1733310593; bh=6AwESIuz7ykjlck03k727WR/pQPVsoRXjWoCd5no3oU=; h=From:To:Cc:Subject:Date:From; b=Riu9pgtW7JK9oh8vcRnfZ8R19WMrQBMQOeyOyStkYmrmrvOohrYey9pgu1gy3VH4A as9PzTzCywYIn/neCY7CGN9Zh1KHBcX7Le+HAvJXCI6v/lBLxvEF8RU5PHVJ5+RFG7 PBbDlfOtndVsLUbKFmG8d8deUmtFN/eLHV2XSz2I= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH] libcamera: yaml_parser: Output more details when parsing fails Date: Wed, 4 Dec 2024 12:10:13 +0100 Message-ID: <20241204111017.343760-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 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" On malformed yaml files, the yaml parser only errors out without giving details on the error that happened. Fix that by providing a more detailed error message. Output old: ERROR YamlParser yaml_parser.cpp:886 Failed to parse YAML content from /root/imx283.yaml Output new: ERROR YamlParser yaml_parser.cpp:627 /root/imx283.yaml:72:8 could not find expected ':' while scanning a simple key ERROR YamlParser yaml_parser.cpp:886 Failed to parse YAML content from /root/imx283.yaml Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/yaml_parser.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp index db256ec5b04d..f9302c4ee3fa 100644 --- a/src/libcamera/yaml_parser.cpp +++ b/src/libcamera/yaml_parser.cpp @@ -509,8 +509,17 @@ YamlParserContext::EventPtr YamlParserContext::nextEvent() EventPtr event(new yaml_event_t); /* yaml_parser_parse returns 1 when it succeeds */ - if (!yaml_parser_parse(&parser_, event.get())) + if (!yaml_parser_parse(&parser_, event.get())) { + File *file = static_cast(parser_.read_handler_data); + + LOG(YamlParser, Error) << file->fileName() << ":" + << parser_.problem_mark.line << ":" + << parser_.problem_mark.column << " " + << parser_.problem << " " + << parser_.context; + return nullptr; + } return event; }