[{"id":18259,"web_url":"https://patchwork.libcamera.org/comment/18259/","msgid":"<20210722125244.jnhks72s3inz5hs7@uno.localdomain>","date":"2021-07-22T12:52:44","subject":"Re: [libcamera-devel] [PATCH v3 12/33] cam: stream_options: Use\n\tOptionValue::empty() to test if option is set","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Fri, Jul 16, 2021 at 12:14:38AM +0300, Laurent Pinchart wrote:\n> The roles() and updateConfiguration() functions check if the OptStream\n> OptionValue they receive is empty by first casting it to an array. To\n> prepare for the toArray() function not allowing such a cast when the\n> option value is empty, test if the option value is empty instead.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n> ---\n>  src/cam/stream_options.cpp | 12 ++++++------\n>  1 file changed, 6 insertions(+), 6 deletions(-)\n>\n> diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp\n> index b90dbb97f087..150bd27caecf 100644\n> --- a/src/cam/stream_options.cpp\n> +++ b/src/cam/stream_options.cpp\n> @@ -40,12 +40,12 @@ KeyValueParser::Options StreamKeyValueParser::parse(const char *arguments)\n>\n>  StreamRoles StreamKeyValueParser::roles(const OptionValue &values)\n>  {\n> -\tconst std::vector<OptionValue> &streamParameters = values.toArray();\n> -\n>  \t/* If no configuration values to examine default to viewfinder. */\n> -\tif (streamParameters.empty())\n> +\tif (values.empty())\n>  \t\treturn { StreamRole::Viewfinder };\n>\n> +\tconst std::vector<OptionValue> &streamParameters = values.toArray();\n> +\n>  \tStreamRoles roles;\n>  \tfor (auto const &value : streamParameters) {\n>  \t\tStreamRole role;\n> @@ -63,17 +63,17 @@ StreamRoles StreamKeyValueParser::roles(const OptionValue &values)\n>  int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config,\n>  \t\t\t\t\t      const OptionValue &values)\n>  {\n> -\tconst std::vector<OptionValue> &streamParameters = values.toArray();\n> -\n>  \tif (!config) {\n>  \t\tstd::cerr << \"No configuration provided\" << std::endl;\n>  \t\treturn -EINVAL;\n>  \t}\n>\n>  \t/* If no configuration values nothing to do. */\n> -\tif (!streamParameters.size())\n> +\tif (values.empty())\n>  \t\treturn 0;\n>\n> +\tconst std::vector<OptionValue> &streamParameters = values.toArray();\n> +\n>  \tif (config->size() != streamParameters.size()) {\n>  \t\tstd::cerr\n>  \t\t\t<< \"Number of streams in configuration \"\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 87E85C322B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jul 2021 12:51:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4D59D68543;\n\tThu, 22 Jul 2021 14:51:58 +0200 (CEST)","from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net\n\t[217.70.183.195])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 95D326027A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jul 2021 14:51:57 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 1AF7060005;\n\tThu, 22 Jul 2021 12:51:56 +0000 (UTC)"],"Date":"Thu, 22 Jul 2021 14:52:44 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210722125244.jnhks72s3inz5hs7@uno.localdomain>","References":"<20210715211459.19373-1-laurent.pinchart@ideasonboard.com>\n\t<20210715211459.19373-13-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210715211459.19373-13-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 12/33] cam: stream_options: Use\n\tOptionValue::empty() to test if option is set","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]