From patchwork Wed Aug 3 11:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 16954 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 6E930C3272 for ; Wed, 3 Aug 2022 11:29:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F291763310; Wed, 3 Aug 2022 13:29:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659526185; bh=+25sZo3CHG8TGWXPT1zugAAONI1GzhZRWTOcwIdDHoY=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oG0ZXMMXkn0NbKMrtykDTZ5GUozvEtnI/Lfnv+lyOKuVr/PRbKhXccKZr2u33LrtC xLjaz3UlZJr0HoesKn3uAXGEPty2X+wCwx2xb0AE8jYkdhF3USzVoUP+wN04+EGB9N KHGHO2t9Xaz8ovBLqjLiw7t59re+sZyZlvFKAy5fg/7NLtjV6+3I1G/lt10LqZn0qi Y6Ev41I5WSgFJxVlPyqpZHTelyEyQEweIQLWViI6puZDD413CiHRJN9RzZdtgA6WOC 8ejlp6qp40Kn7rq8ap52U1jbFXcBTPfgwdVlWjXwJkwpG+4Py+zzD14yk8ZYZYYfOB n8f6PhH224OdA== Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 60E94603E6 for ; Wed, 3 Aug 2022 13:29:44 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 3CE0F1C000E; Wed, 3 Aug 2022 11:29:42 +0000 (UTC) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Aug 2022 13:29:37 +0200 Message-Id: <20220803112937.30566-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] 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 returns an empty vector in case of parsing errors, which evaluates to std::nullopt but it less explicit. Change this by returning std::nullopt in case of errors to make the intended behaviour more explicit. Signed-off-by: Jacopo Mondi Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- 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); }