From patchwork Wed Aug 3 11:03:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16934 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 A35FCC3272 for ; Wed, 3 Aug 2022 11:03:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D34861FAE; Wed, 3 Aug 2022 13:03:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659524611; bh=7EfPKvlrGAAJUdW/QgxczMO0d7s0IMn5wzTLSuBwfAA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=BhzKEYJ97kbYLkG6dr1Ug6VvLDZRN3kTS1/tfjgJUrdAqwZVDHRjEBEvLYkHqcNqa GTLatajoysyLaz1zh4WCVhkYpCKLUGfQMRHmoGMGnW7WfKhJ5xDeAzeLimWy1biS+/ SMHI30CW6ahbQ4D7ZlJF8bOubGSUWDKcU0Wz6nHxAQvbNLGOg3R3FdggniQFnrYwBz WWS2pnwCVFbV+CmLvKx32jYWAW2wn8tjsFota+Vb6kTw4PlrSqyLD6q4wC+TqS9Zcn 43HfZi0qHAHsan1iSnWVsbON9KmwzGmOilEpDZyvtr61vwcDh7JKyuHcWeYxMjJxpc ELYPTN72H4GSg== Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9203C603E6 for ; Wed, 3 Aug 2022 13:03:30 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id E38661C0006; Wed, 3 Aug 2022 11:03:29 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 13:03:24 +0200 Message-Id: <20220803110324.28539-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: yaml_parser: Return nullopt on error 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: , X-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The YamlParser::getList<>() function returns an std::optional<> to allow callers to identify cases where parsing the .yaml file failed from cases where the parsed list is just empty. The current implementation however returns an empty list in case of errors, making it impossible for the caller to detect parsing failures. Fix this by returning std::nullopt in case of errors. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder --- src/libcamera/yaml_parser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp index 84cb57d6de83..c96e99e1317c 100644 --- a/src/libcamera/yaml_parser.cpp +++ b/src/libcamera/yaml_parser.cpp @@ -319,7 +319,7 @@ template> YamlObject::getList() const { if (type_ != Type::List) - return {}; + return std::nullopt; std::vector values; values.reserve(list_.size()); @@ -327,7 +327,7 @@ std::optional> YamlObject::getList() const for (const YamlObject &entry : asList()) { const auto value = entry.get(); if (!value) - return {}; + return std::nullopt; values.emplace_back(*value); }