From patchwork Thu Jul 15 21:14:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12983 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 7D56DC3226 for ; Thu, 15 Jul 2021 21:15:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F0F206854A; Thu, 15 Jul 2021 23:15:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hihWU3iS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 929E868539 for ; Thu, 15 Jul 2021 23:15:08 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 282BC340 for ; Thu, 15 Jul 2021 23:15:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626383708; bh=Vkh0ETeAXWiugU82j7iAZryFOaWpBSN7HlI/fPLcuZY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hihWU3iSMu4lb2rllS2ccSwXot8EBty6/iBRlxQd6mKXQjgmM9HrvqI78Zv2OX5U2 VCLIIR/FGVJ8Bn2mcQ1IFi85ffSENKXUn+AJ7QU2ETtOPJdnX9GWkZhgbjTsYDbfj9 Omb6eVVxbmexAySukcCp2HsuxV5KFBlilBFhKTD0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Jul 2021 00:14:38 +0300 Message-Id: <20210715211459.19373-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> References: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 12/33] cam: stream_options: Use OptionValue::empty() to test if option is set 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" The roles() and updateConfiguration() functions check if the OptStream OptionValue they receive is empty by first casting it to an array. To prepare for the toArray() function not allowing such a cast when the option value is empty, test if the option value is empty instead. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/cam/stream_options.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp index b90dbb97f087..150bd27caecf 100644 --- a/src/cam/stream_options.cpp +++ b/src/cam/stream_options.cpp @@ -40,12 +40,12 @@ KeyValueParser::Options StreamKeyValueParser::parse(const char *arguments) StreamRoles StreamKeyValueParser::roles(const OptionValue &values) { - const std::vector &streamParameters = values.toArray(); - /* If no configuration values to examine default to viewfinder. */ - if (streamParameters.empty()) + if (values.empty()) return { StreamRole::Viewfinder }; + const std::vector &streamParameters = values.toArray(); + StreamRoles roles; for (auto const &value : streamParameters) { StreamRole role; @@ -63,17 +63,17 @@ StreamRoles StreamKeyValueParser::roles(const OptionValue &values) int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config, const OptionValue &values) { - const std::vector &streamParameters = values.toArray(); - if (!config) { std::cerr << "No configuration provided" << std::endl; return -EINVAL; } /* If no configuration values nothing to do. */ - if (!streamParameters.size()) + if (values.empty()) return 0; + const std::vector &streamParameters = values.toArray(); + if (config->size() != streamParameters.size()) { std::cerr << "Number of streams in configuration "