[{"id":23982,"web_url":"https://patchwork.libcamera.org/comment/23982/","msgid":"<CAEmqJPr67BehwT1W71utOeHhsB4zkzWcOyoAdcWh9vX6xqK_fA@mail.gmail.com>","date":"2022-07-20T08:17:45","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Wed, 20 Jul 2022 at 09:15, Naushir Patuck <naush@raspberrypi.com> wrote:\n\n> Now that ControlList::get() returns a std::optional<T> to handle missing\n> controls, the error log message in the call to ControlList::find() is\n> unnecessary and likely invalid.\n>\n> Fix this by avoding the call to ControlList::find() from\n> ControlList::get() and\n> replacing with a call to the underlying std::unordered_map::find().\n>\n> Fixes: 1c4d48018505 (\"libcamera: controls: Use std::optional to handle\n> invalid control values\")\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  include/libcamera/controls.h | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 192be78434dc..8362fce813fb 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -376,11 +376,12 @@ public:\n>         template<typename T>\n>         std::optional<T> get(const Control<T> &ctrl) const\n>         {\n> -               const ControlValue *val = find(ctrl.id());\n> -               if (!val)\n> +               const auto entry = controls_.find(ctrl.id());\n> +               if (entry == controls_.end())\n>                         return std::nullopt;\n>\n> -               return val->get<T>();\n> +               const ControlValue &val = entry->second;\n> +               return val.get<T>();\n>\n\nBonus marks if somebody could explain to me why I need to cast\nentry->second to a const for get() to work...?  If I don't, the following\nstatement:\n\nreturn entry->second.get<T>()\n\nreturns the following compile error:\n\n../include/libcamera/controls.h: In member function ‘std::optional<_Tp>\nlibcamera::ControlList::get(const libcamera::Control<T>&) const’:\n../include/libcamera/controls.h:384:33: error: expected primary-expression\nbefore ‘>’ token\n  384 |   return ((entry->second)).get<T>();\n      |                                 ^\n../include/libcamera/controls.h:384:35: error: expected primary-expression\nbefore ‘)’ token\n  384 |   return ((entry->second)).get<T>();\n\n?\n\n\n>         }\n>\n>         template<typename T, typename V>\n> --\n> 2.25.1\n>\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 9A0AEBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Jul 2022 08:18:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DAFF763314;\n\tWed, 20 Jul 2022 10:18:04 +0200 (CEST)","from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com\n\t[IPv6:2a00:1450:4864:20::22c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E597560488\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jul 2022 10:18:02 +0200 (CEST)","by mail-lj1-x22c.google.com with SMTP id a10so20246320ljj.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jul 2022 01:18:02 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658305084;\n\tbh=783xWnL2fH+LxBHjpkb//fxDK0WhxrZHNffVsbjTsNQ=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=vFs4KV3pjIu5Lzixp49aOMXnGAbc2QFdEVvjTH+qtHWwbRo7uPQmv9WoBZu7Da3Uk\n\tpIBi43L7cvN2c/dr1L45CLtazlhF+gg9Z4LRO1uP+8Z2h3KIUvgRjf5Ma9T4AtUn4x\n\tSyWvyqayHM8KqgGecCDV43/0pcWwEhYp6mFqUKCd5Xxfd93tnxju2Ro0y1L0O8kd0S\n\tpmyrul3uCMiMWcXnxAsBCSeM2+KbCAVp3bWxqOTtpxEdkCqcmzeE0eD2iwNmtf/6z2\n\ttWlc1JJGs+9727C0HktBOMW36agoqZKW93XKsKg9DC/8PkyrIHDL+o500rbQYH3RkJ\n\tuSNUfTiQmtg0g==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to;\n\tbh=JUPWnDmdRkJJZq3VoM+YAAEi+j+cnVfysQrEfUKkQmY=;\n\tb=XoUHmnVqsDBIguyAgsidRXRcV8hQkfgobc+jECMkVEdHjx/aFt4BOHNTO7J8f25zH4\n\tBfh5WPA4Dk3CiIe3SHBhUkZE5Y62CcZ1HUeni6mdvremiyk8GtdRzPSj1fvF0Haoh/AL\n\t7MLd4EaNW10DUDjNcjdI7Md4+PvOEysEjZ50BvxHPZxG+bcikrW7BqEJEQJuRDPSAMqH\n\tehkewmpEejCsUbHxAm8XbT/Mq92IqXTBecfliu2cXzFqUp6GT7Y4Od9EaAcCliAFE9Sq\n\tg88esaN5mUlexWb6YBymL32FVAVTkFFboYnAbf2N3ekU3icX9h7mKB7L0+DPhX7zqaRl\n\tbuHg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"XoUHmnVq\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to;\n\tbh=JUPWnDmdRkJJZq3VoM+YAAEi+j+cnVfysQrEfUKkQmY=;\n\tb=NYPN0bSNyXnXP8t++TxQAFhTv3qmNxvAbSF46+DYTDmwYBfst0Uq+6KF/N+Id8riWx\n\tj/ZJIFWGEpCSuZUtyagPjeCTaCjauJD9ZtsInTQAOxJlmteQaYKYHSs9tOa2g8sG7zHm\n\tDLam2MudJaBN9TCUfmKOQSSPEAWsgUFWYL4dNZnUPCxpvCsKElF+e0vhEdboD78YM7ZJ\n\t0b92A7D1BfP7chH+UTJjHv1eraTTuRuA5tqj3jIu9gI9vHMCgAj0Pyob97Unh2PEO9xj\n\tKpZYUrCusrBPjmN0O1d0dfRP+C8pyamkm8hj2JCSd+PMTzThK3s+nMtlZ9ffuMMNTnwY\n\t/Eaw==","X-Gm-Message-State":"AJIora/nyfoeEGHwNW8OsMxHpSpTv3zlgMxIFJOnaKhrg+Ya5TrGot+1\n\tGSyvyWE526huSq8sRCjkUFkK6T+XpGObhDiXQm9r7DLpVE/irN/q","X-Google-Smtp-Source":"AGRyM1tO5YBX3EJOAHaYHqAd+YSxngtc7MwrKQTM9zKdFRig+AieUPSRkLj8mp8fKgh5uVE8Mj24OBNWWrXBKRlyrxQ=","X-Received":"by 2002:a2e:7807:0:b0:25d:9008:97fe with SMTP id\n\tt7-20020a2e7807000000b0025d900897femr15855442ljc.279.1658305081173;\n\tWed, 20 Jul 2022 01:18:01 -0700 (PDT)","MIME-Version":"1.0","References":"<20220720081534.26400-1-naush@raspberrypi.com>","In-Reply-To":"<20220720081534.26400-1-naush@raspberrypi.com>","Date":"Wed, 20 Jul 2022 09:17:45 +0100","Message-ID":"<CAEmqJPr67BehwT1W71utOeHhsB4zkzWcOyoAdcWh9vX6xqK_fA@mail.gmail.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/alternative; boundary=\"0000000000004b008705e4383d27\"","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23983,"web_url":"https://patchwork.libcamera.org/comment/23983/","msgid":"<Yte8a9VcSkE2XLUC@pendragon.ideasonboard.com>","date":"2022-07-20T08:27:23","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Wed, Jul 20, 2022 at 09:15:34AM +0100, Naushir Patuck via libcamera-devel wrote:\n> Now that ControlList::get() returns a std::optional<T> to handle missing\n> controls, the error log message in the call to ControlList::find() is\n> unnecessary and likely invalid.\n> \n> Fix this by avoding the call to ControlList::find() from ControlList::get() and\n\ns/avoding/avoiding/\n\n> replacing with a call to the underlying std::unordered_map::find().\n> \n> Fixes: 1c4d48018505 (\"libcamera: controls: Use std::optional to handle invalid control values\")\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/controls.h | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 192be78434dc..8362fce813fb 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -376,11 +376,12 @@ public:\n>  \ttemplate<typename T>\n>  \tstd::optional<T> get(const Control<T> &ctrl) const\n>  \t{\n> -\t\tconst ControlValue *val = find(ctrl.id());\n> -\t\tif (!val)\n> +\t\tconst auto entry = controls_.find(ctrl.id());\n> +\t\tif (entry == controls_.end())\n>  \t\t\treturn std::nullopt;\n>  \n> -\t\treturn val->get<T>();\n> +\t\tconst ControlValue &val = entry->second;\n> +\t\treturn val.get<T>();\n>  \t}\n>  \n>  \ttemplate<typename T, typename V>","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 CAC27BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Jul 2022 08:28:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3841863313;\n\tWed, 20 Jul 2022 10:28:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D3BC60488\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jul 2022 10:27:58 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E8F936DB;\n\tWed, 20 Jul 2022 10:27:57 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658305680;\n\tbh=qukoAew2wZPMfZhwS+qzleiowxVmzsDgi5XMs5GaVOM=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=cdeJUkiV+1QAGHESsQ1llDwhdhXVmfrgnkhvqgV4DXb24WzIxhfrFueaiyIr5rXm2\n\tW1buvr/wu/11X/Rx4/GW0mAgXZENu4VbeQXVs/CnH3BxKCf/HMunlDq+qXchbjQD1G\n\tYYLLu/OqIDRiGn2ffzQhmsBXbFZg/PNu21ks5rJxbIIYd+rWQCxwdk2W5BbwCZj3zD\n\t6EqiHrZN1pcJny6MmJfD/65d7tFnUHItQBAshmjWUK/bzxVE23R5wDJ48ByGMcOlbL\n\tRAkXxs42Bro9UJp3EAcn1Obs2tyA5T566o3EEz/LaTubn58Zn41pvnifa3ePPHyXuz\n\t4MgoNhukvY4Qw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658305678;\n\tbh=qukoAew2wZPMfZhwS+qzleiowxVmzsDgi5XMs5GaVOM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=C+nCQAqHKaWw+W4VEC73e48QSycpRiQjwwEfAvXMVylH2N+1AXOgZ7JhGp5cC/46b\n\tBdfVxw2079gVT42mnLyh06+q9ajPhmzDbKa5eW9RxeuDQb4HXyCPSc49hDwPx8ybY/\n\tFH/5Px8tJ0x6AEsN8KXm5c0DruuGWyf1H28VsXwU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"C+nCQAqH\"; dkim-atps=neutral","Date":"Wed, 20 Jul 2022 11:27:23 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Yte8a9VcSkE2XLUC@pendragon.ideasonboard.com>","References":"<20220720081534.26400-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220720081534.26400-1-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24001,"web_url":"https://patchwork.libcamera.org/comment/24001/","msgid":"<4bd19d68-3a1d-6e75-bc07-0a19674c6c8a@ideasonboard.com>","date":"2022-07-20T10:10:50","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch\n\nOn 7/20/22 13:45, Naushir Patuck via libcamera-devel wrote:\n> Now that ControlList::get() returns a std::optional<T> to handle missing\n> controls, the error log message in the call to ControlList::find() is\n> unnecessary and likely invalid.\n>\n> Fix this by avoding the call to ControlList::find() from ControlList::get() and\n> replacing with a call to the underlying std::unordered_map::find().\n>\n> Fixes: 1c4d48018505 (\"libcamera: controls: Use std::optional to handle invalid control values\")\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\n\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n\n> ---\n>   include/libcamera/controls.h | 7 ++++---\n>   1 file changed, 4 insertions(+), 3 deletions(-)\n>\n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 192be78434dc..8362fce813fb 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -376,11 +376,12 @@ public:\n>   \ttemplate<typename T>\n>   \tstd::optional<T> get(const Control<T> &ctrl) const\n>   \t{\n> -\t\tconst ControlValue *val = find(ctrl.id());\n> -\t\tif (!val)\n> +\t\tconst auto entry = controls_.find(ctrl.id());\n> +\t\tif (entry == controls_.end())\n>   \t\t\treturn std::nullopt;\n>   \n> -\t\treturn val->get<T>();\n> +\t\tconst ControlValue &val = entry->second;\n> +\t\treturn val.get<T>();\n>   \t}\n>   \n>   \ttemplate<typename T, typename V>","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 244DEBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Jul 2022 10:11:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8E4F160489;\n\tWed, 20 Jul 2022 12:11:07 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 02A38601B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jul 2022 12:11:05 +0200 (CEST)","from [192.168.1.110] (unknown [110.226.27.196])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C0A3C6DB;\n\tWed, 20 Jul 2022 12:11:04 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658311867;\n\tbh=1kPY0OVLSGRi1Sq3QHj1btQ5+WYR8ECSg9iFNdhA6oI=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=XKMufCbpRcHcX5jw+xFBVRCfYs1zgX+cCL1igXm/m1yrYX/8E1PdfI6+fdh9rCDst\n\tzFt7Rn7f+vLxaLxRaZzQ7FI4lKlBlx9RPZFOOCERexBeis/86lbHuCDRVDuKNDrE+Z\n\txcBhmf1lVxHRd1aTEVgd/dCQaQ6be+N4/Ao1n4qclCYRXYdmZb/BmzynvGX5oUveNG\n\tQBvYfW6p7UqK07prTQQtdH6+vxth1cxNUhEAHCAabYTAFFAE4OeDvEyap7D5D3eu8X\n\tojjsuDJNHJrCZLCG525c3Pu05elznr2D0IYPgJ6otrdCRlyLkAlSP8ECPIC6PM8rnZ\n\t2M82j7HRxiJIg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658311865;\n\tbh=1kPY0OVLSGRi1Sq3QHj1btQ5+WYR8ECSg9iFNdhA6oI=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=MsPAU/rxNDMlbNM50mbLxxoJish8reX0yf2ukNmTSq4NyC7rg+TSWNOwrID6ueXRi\n\t4sSqkl2Z6Hhw9IxdJmAiEisiTd11hdot5vK1a/FdlrZ1ZhDwIbuZDsFo48m0TjZ08A\n\tp6Xhv/uufAqKwQGidi2SI/oiGecqni2fv8uYIyQw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"MsPAU/rx\"; dkim-atps=neutral","Message-ID":"<4bd19d68-3a1d-6e75-bc07-0a19674c6c8a@ideasonboard.com>","Date":"Wed, 20 Jul 2022 15:40:50 +0530","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.4.1","Content-Language":"en-US","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20220720081534.26400-1-naush@raspberrypi.com>","In-Reply-To":"<20220720081534.26400-1-naush@raspberrypi.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","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>","From":"Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Umang Jain <umang.jain@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24002,"web_url":"https://patchwork.libcamera.org/comment/24002/","msgid":"<YtfWjDjqdVQ7v/4y@pendragon.ideasonboard.com>","date":"2022-07-20T10:18:52","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Wed, Jul 20, 2022 at 09:17:45AM +0100, Naushir Patuck via libcamera-devel wrote:\n> On Wed, 20 Jul 2022 at 09:15, Naushir Patuck wrote:\n> \n> > Now that ControlList::get() returns a std::optional<T> to handle missing\n> > controls, the error log message in the call to ControlList::find() is\n> > unnecessary and likely invalid.\n> >\n> > Fix this by avoding the call to ControlList::find() from\n> > ControlList::get() and\n> > replacing with a call to the underlying std::unordered_map::find().\n> >\n> > Fixes: 1c4d48018505 (\"libcamera: controls: Use std::optional to handle\n> > invalid control values\")\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  include/libcamera/controls.h | 7 ++++---\n> >  1 file changed, 4 insertions(+), 3 deletions(-)\n> >\n> > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> > index 192be78434dc..8362fce813fb 100644\n> > --- a/include/libcamera/controls.h\n> > +++ b/include/libcamera/controls.h\n> > @@ -376,11 +376,12 @@ public:\n> >         template<typename T>\n> >         std::optional<T> get(const Control<T> &ctrl) const\n> >         {\n> > -               const ControlValue *val = find(ctrl.id());\n> > -               if (!val)\n> > +               const auto entry = controls_.find(ctrl.id());\n> > +               if (entry == controls_.end())\n> >                         return std::nullopt;\n> >\n> > -               return val->get<T>();\n> > +               const ControlValue &val = entry->second;\n> > +               return val.get<T>();\n> \n> Bonus marks if somebody could explain to me why I need to cast\n> entry->second to a const for get() to work...?  If I don't, the following\n> statement:\n> \n> return entry->second.get<T>()\n> \n> returns the following compile error:\n> \n> ../include/libcamera/controls.h: In member function ‘std::optional<_Tp>\n> libcamera::ControlList::get(const libcamera::Control<T>&) const’:\n> ../include/libcamera/controls.h:384:33: error: expected primary-expression\n> before ‘>’ token\n>   384 |   return ((entry->second)).get<T>();\n>       |                                 ^\n> ../include/libcamera/controls.h:384:35: error: expected primary-expression\n> before ‘)’ token\n>   384 |   return ((entry->second)).get<T>();\n> \n> ?\n\nYou need to write\n\n\treturn entry->second.template get<T>();\n\nQuoting the C++ standard,\n\nWhen the name of a member template specialization appears after . or ->\nin a postfix-expression, or after nested-name-specifier in a\nqualified-id, and the postfix-expression or qualified-id explicitly\ndepends on a template-parameter (14.6.2), the member template name must\nbe prefixed by the keyword template. Otherwise the name is assumed to\nname a non-template.\n\nThe \"The template disambiguator for dependent names\" section in\nhttps://en.cppreference.com/w/cpp/language/dependent_name is easier to\nunderstand for us humans (I didn't say easy though).\n\n> >         }\n> >\n> >         template<typename T, typename V>","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 68CFDBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Jul 2022 10:19:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9A52C63310;\n\tWed, 20 Jul 2022 12:19:27 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8C546601B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Jul 2022 12:19:26 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 079686DB;\n\tWed, 20 Jul 2022 12:19:25 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658312367;\n\tbh=TjM9Q0d6WlWaHqa9F5R61GaH7ikajWnFm7rBtV0ndzQ=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=u/wmbHodew8l+xaKg9fdAgCXYnXgaXSZZ3C9tf9kcqcw1nEF8hja/e9as7CWA3X+J\n\tAryKeMW3h8tknBgdtlzDaJU3aX2GRQ9rF0IXAJc0dTssdPPDUf0OgWhMirsd8ON4at\n\tj9//rjbfSIwD92S+8vVlkb/HCYz9MQEEZRWTs0Cwjz3p/34q3ZnOCfj8w5mZgFCmUb\n\t2rJQe0pRDagSo252kP3AINvIjaKNOrLqs1mM2XX3xpKtIlKU6WJNYXJKpmfZBkzG3V\n\tqTbL1q0e3c9itB7t6BmoHap/I1hmOV38P+8QyvJ/XElmYQnFvo9ho+3jFM/dlpu5Ow\n\tw+APAgZHnPprQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658312366;\n\tbh=TjM9Q0d6WlWaHqa9F5R61GaH7ikajWnFm7rBtV0ndzQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bV6NlOJk/JIvlSRB833QfI+GlUrq849SSHE40OwyqewthD2BMkPcEVldEqGvD/GH1\n\twgiDeX68qYQf0zMBw0KHJ6tAd+ZraOxEHAliE6ZVqKtEooT5LHpjuuP5/HDFBSrOFK\n\tvG3RTrMs1Q3Dnp1SrQ5dafbVSfor2PeD6ZDs3A2A="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"bV6NlOJk\"; dkim-atps=neutral","Date":"Wed, 20 Jul 2022 13:18:52 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YtfWjDjqdVQ7v/4y@pendragon.ideasonboard.com>","References":"<20220720081534.26400-1-naush@raspberrypi.com>\n\t<CAEmqJPr67BehwT1W71utOeHhsB4zkzWcOyoAdcWh9vX6xqK_fA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAEmqJPr67BehwT1W71utOeHhsB4zkzWcOyoAdcWh9vX6xqK_fA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24012,"web_url":"https://patchwork.libcamera.org/comment/24012/","msgid":"<CAEmqJPr2kHK93q8xf9tMBUDB6NvsPSZDXC4KmTkj8BcO-q3vew@mail.gmail.com>","date":"2022-07-21T07:04:32","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nOn Wed, 20 Jul 2022 at 11:19, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Naush,\n>\n> On Wed, Jul 20, 2022 at 09:17:45AM +0100, Naushir Patuck via\n> libcamera-devel wrote:\n> > On Wed, 20 Jul 2022 at 09:15, Naushir Patuck wrote:\n> >\n> > > Now that ControlList::get() returns a std::optional<T> to handle\n> missing\n> > > controls, the error log message in the call to ControlList::find() is\n> > > unnecessary and likely invalid.\n> > >\n> > > Fix this by avoding the call to ControlList::find() from\n> > > ControlList::get() and\n> > > replacing with a call to the underlying std::unordered_map::find().\n> > >\n> > > Fixes: 1c4d48018505 (\"libcamera: controls: Use std::optional to handle\n> > > invalid control values\")\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > ---\n> > >  include/libcamera/controls.h | 7 ++++---\n> > >  1 file changed, 4 insertions(+), 3 deletions(-)\n> > >\n> > > diff --git a/include/libcamera/controls.h\n> b/include/libcamera/controls.h\n> > > index 192be78434dc..8362fce813fb 100644\n> > > --- a/include/libcamera/controls.h\n> > > +++ b/include/libcamera/controls.h\n> > > @@ -376,11 +376,12 @@ public:\n> > >         template<typename T>\n> > >         std::optional<T> get(const Control<T> &ctrl) const\n> > >         {\n> > > -               const ControlValue *val = find(ctrl.id());\n> > > -               if (!val)\n> > > +               const auto entry = controls_.find(ctrl.id());\n> > > +               if (entry == controls_.end())\n> > >                         return std::nullopt;\n> > >\n> > > -               return val->get<T>();\n> > > +               const ControlValue &val = entry->second;\n> > > +               return val.get<T>();\n> >\n> > Bonus marks if somebody could explain to me why I need to cast\n> > entry->second to a const for get() to work...?  If I don't, the following\n> > statement:\n> >\n> > return entry->second.get<T>()\n> >\n> > returns the following compile error:\n> >\n> > ../include/libcamera/controls.h: In member function ‘std::optional<_Tp>\n> > libcamera::ControlList::get(const libcamera::Control<T>&) const’:\n> > ../include/libcamera/controls.h:384:33: error: expected\n> primary-expression\n> > before ‘>’ token\n> >   384 |   return ((entry->second)).get<T>();\n> >       |                                 ^\n> > ../include/libcamera/controls.h:384:35: error: expected\n> primary-expression\n> > before ‘)’ token\n> >   384 |   return ((entry->second)).get<T>();\n> >\n> > ?\n>\n> You need to write\n>\n>         return entry->second.template get<T>();\n>\n> Quoting the C++ standard,\n>\n> When the name of a member template specialization appears after . or ->\n> in a postfix-expression, or after nested-name-specifier in a\n> qualified-id, and the postfix-expression or qualified-id explicitly\n> depends on a template-parameter (14.6.2), the member template name must\n> be prefixed by the keyword template. Otherwise the name is assumed to\n> name a non-template.\n>\n> The \"The template disambiguator for dependent names\" section in\n> https://en.cppreference.com/w/cpp/language/dependent_name is easier to\n> understand for us humans (I didn't say easy though).\n>\n\nWow, I would have never ever guessed that as a solution :-)\n\nNaush\n\n\n\n>\n> > >         }\n> > >\n> > >         template<typename T, typename V>\n>\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 47315BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jul 2022 07:04:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7970E63312;\n\tThu, 21 Jul 2022 09:04:51 +0200 (CEST)","from mail-lf1-x135.google.com (mail-lf1-x135.google.com\n\t[IPv6:2a00:1450:4864:20::135])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 65946603F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jul 2022 09:04:49 +0200 (CEST)","by mail-lf1-x135.google.com with SMTP id r9so1327997lfp.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jul 2022 00:04:49 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658387091;\n\tbh=HrCEYd3nfzte9qNEATi7hUdcvKTySUD1+72s2vQz9KQ=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=sTWq4fqEk3EFp+RKw0Cv8BNvBVJ1EhinJKy2XnD291Vw5+hlHpNNenRSFnRM5JuiK\n\tTScnp6QPeGHsFgH5mzkpCxFaYLiNSb9TvGpaqsyGlNnL3Jk2wiBawcbrgJJI3wPawP\n\tPu6ayaGV3AEqSpfmuctejyS1xiQt7GYGd2MZjPSe6EzFPUmUG01m7RucchiilBDaRr\n\thQIpSTPix8zQuD1ExNT/OJL2r7jmRgxBOfX6GepzWkctR8YppfDjl7G0m3uZvgQGCD\n\tfLkKkKnhRHfryI6X1Ee8g0GZqS4yCD6ltHJpsqHYiVJG0dflWfnOZVLbPIWp2TDNVA\n\tlfvSTX7f5uy7A==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=sAKHOEmNpOjdD450ZqrpXyY8iMzsFSAI518xa7nNv00=;\n\tb=LOlWxryPWK9LGHC+4u/JOMiCKs7xhRRvQxpvTxjSqnKgiAeCYu0ilqMhgc6Px+22iQ\n\tD7Ts3PBcBtljJYBPJmdtmqqcfY43PocQ6ZmSwliY7Dn1mHLUmKeTpj8Uxbm0FcWtRdhr\n\t2SWGuQ/nwnMn57lRtgi6NmulBtxcQa1U62Bile/PX/b3msorUSxmukIKP3d9hOP9WJnY\n\txbm00YP+cwQpZSCD7VjDm+BckqGfrkYKzdT6tf4Yyt5dKOmVsjG6a4n4QKQmhXBgAxU7\n\tHTAIG+4EhlZ3TeM9ZCFGPmrZC7XgiFPyeKaHWaw1brhreVnN2ipJ3lXkYmuInPcV8O0P\n\tL0qA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"LOlWxryP\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=sAKHOEmNpOjdD450ZqrpXyY8iMzsFSAI518xa7nNv00=;\n\tb=WUzgqB8rPH6e+rjeQrdatrTH3JbUe7quQzZAQRVpdUrEKbBVGkryouonMpIQsK4AHI\n\tdU1Or8NHWDyDZb+qmD4J+bfNvdCSNS2BEzpy6xQhEFgGevvoWtWr60ZSQTmqavgsKic6\n\tMqqKEbrEbwknoG7hXJdY2Wl0xk2Jq5YQDixPgjPZMZAc3s54DvmbTXgfQX+nnXc7yXX+\n\tVFPzBfLlGPkGSaatznWQEAaK343/+nTHwvezgr81QVXrQTsTBnsdezDq0dheXXQ1O+vT\n\ticdixDcf34D4d/d40TrH1K1ZfvPZre+ChlDkcu/fy/Cxd2TVxJP/M841mq5St3Pxuhkg\n\tn4eg==","X-Gm-Message-State":"AJIora96kA26v60tdJAjQHn9HmvPJzEh+XrYx5EWkX8XdeaSnhWO7l9U\n\tT9N7PRB/nPgE6J+54tTUwBzDiiO9MILfbnmst2/WN0P4Yvv5XA==","X-Google-Smtp-Source":"AGRyM1tMTHSFLXb425/EWeFhHUCDtY9M0EqVJXgcCRoGJ4Qbtz7PhUECFGvj03rnj+UFxPvrHtwM2LOG305RSb860L8=","X-Received":"by 2002:ac2:46fa:0:b0:48a:1c7c:9cef with SMTP id\n\tq26-20020ac246fa000000b0048a1c7c9cefmr16285428lfo.682.1658387088300;\n\tThu, 21 Jul 2022 00:04:48 -0700 (PDT)","MIME-Version":"1.0","References":"<20220720081534.26400-1-naush@raspberrypi.com>\n\t<CAEmqJPr67BehwT1W71utOeHhsB4zkzWcOyoAdcWh9vX6xqK_fA@mail.gmail.com>\n\t<YtfWjDjqdVQ7v/4y@pendragon.ideasonboard.com>","In-Reply-To":"<YtfWjDjqdVQ7v/4y@pendragon.ideasonboard.com>","Date":"Thu, 21 Jul 2022 08:04:32 +0100","Message-ID":"<CAEmqJPr2kHK93q8xf9tMBUDB6NvsPSZDXC4KmTkj8BcO-q3vew@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"0000000000004c7aa605e44b5501\"","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24014,"web_url":"https://patchwork.libcamera.org/comment/24014/","msgid":"<Ytj8ObA7qOENp4wc@pendragon.ideasonboard.com>","date":"2022-07-21T07:11:53","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Thu, Jul 21, 2022 at 08:04:32AM +0100, Naushir Patuck wrote:\n> On Wed, 20 Jul 2022 at 11:19, Laurent Pinchart wrote:\n> > On Wed, Jul 20, 2022 at 09:17:45AM +0100, Naushir Patuck via libcamera-devel wrote:\n> > > On Wed, 20 Jul 2022 at 09:15, Naushir Patuck wrote:\n> > >\n> > > > Now that ControlList::get() returns a std::optional<T> to handle missing\n> > > > controls, the error log message in the call to ControlList::find() is\n> > > > unnecessary and likely invalid.\n> > > >\n> > > > Fix this by avoding the call to ControlList::find() from\n> > > > ControlList::get() and\n> > > > replacing with a call to the underlying std::unordered_map::find().\n> > > >\n> > > > Fixes: 1c4d48018505 (\"libcamera: controls: Use std::optional to handle\n> > > > invalid control values\")\n> > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > ---\n> > > >  include/libcamera/controls.h | 7 ++++---\n> > > >  1 file changed, 4 insertions(+), 3 deletions(-)\n> > > >\n> > > > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> > > > index 192be78434dc..8362fce813fb 100644\n> > > > --- a/include/libcamera/controls.h\n> > > > +++ b/include/libcamera/controls.h\n> > > > @@ -376,11 +376,12 @@ public:\n> > > >         template<typename T>\n> > > >         std::optional<T> get(const Control<T> &ctrl) const\n> > > >         {\n> > > > -               const ControlValue *val = find(ctrl.id());\n> > > > -               if (!val)\n> > > > +               const auto entry = controls_.find(ctrl.id());\n> > > > +               if (entry == controls_.end())\n> > > >                         return std::nullopt;\n> > > >\n> > > > -               return val->get<T>();\n> > > > +               const ControlValue &val = entry->second;\n> > > > +               return val.get<T>();\n> > >\n> > > Bonus marks if somebody could explain to me why I need to cast\n> > > entry->second to a const for get() to work...?  If I don't, the following\n> > > statement:\n> > >\n> > > return entry->second.get<T>()\n> > >\n> > > returns the following compile error:\n> > >\n> > > ../include/libcamera/controls.h: In member function ‘std::optional<_Tp>\n> > > libcamera::ControlList::get(const libcamera::Control<T>&) const’:\n> > > ../include/libcamera/controls.h:384:33: error: expected primary-expression before ‘>’ token\n> > >   384 |   return ((entry->second)).get<T>();\n> > >       |                                 ^\n> > > ../include/libcamera/controls.h:384:35: error: expected primary-expression before ‘)’ token\n> > >   384 |   return ((entry->second)).get<T>();\n> > >\n> > > ?\n> >\n> > You need to write\n> >\n> >         return entry->second.template get<T>();\n> >\n> > Quoting the C++ standard,\n> >\n> > When the name of a member template specialization appears after . or ->\n> > in a postfix-expression, or after nested-name-specifier in a\n> > qualified-id, and the postfix-expression or qualified-id explicitly\n> > depends on a template-parameter (14.6.2), the member template name must\n> > be prefixed by the keyword template. Otherwise the name is assumed to\n> > name a non-template.\n> >\n> > The \"The template disambiguator for dependent names\" section in\n> > https://en.cppreference.com/w/cpp/language/dependent_name is easier to\n> > understand for us humans (I didn't say easy though).\n> \n> Wow, I would have never ever guessed that as a solution :-)\n\nAs much as I like C++ and (some aspects of) templates, this is a part of\nthe language that can only be considered as horrible. The decision to\nshape C++ for backward compatibility with C definitely hurts sometimes.\n\n> > > >         }\n> > > >\n> > > >         template<typename T, typename V>","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 74E86BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jul 2022 07:11:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CF9316330E;\n\tThu, 21 Jul 2022 09:11:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DB89C603F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jul 2022 09:11:54 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5029A496;\n\tThu, 21 Jul 2022 09:11:54 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658387516;\n\tbh=ULZKm1dOR11FhNF9iYh9Z6haSaeJ34W3U2g7Wbe6Gu0=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=tI3E9u/FHUQ97By3cJPD1qrJg9Afu8V1akE/aB4pv+GzYMx8w8FcdFKYkxDBqyhqc\n\t34S0LhFNB5x5Y4RHKhhLafCx4XmtKYk/cickk3FjtoOOp84Q+c6ayyOMz9EO3BNMMG\n\tpOHeGqZcG/dCIo1tmk428otYeUoR5DYq2EmTgYW/C9cVpKvz9riNJpcMW1U4gWE2Aj\n\t9NoviBHWxypp/f9keqYECuM0GRXnN6m3r1u5g6ySxVgynLfyduKmMRNmJqITHZqI5I\n\tT4NRkSBE6N21t+jJ1utJOTXtJg5t4Q37m7WLXgKXcd2b9osXRK3vPRn1vaFcy1g91b\n\tgJ8xClYGpKyHw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658387514;\n\tbh=ULZKm1dOR11FhNF9iYh9Z6haSaeJ34W3U2g7Wbe6Gu0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=i60IdIEmX9LoPSdCfhBlbYGNkc4Dt1yrUEkFPMcxyQ0eQP86oaQ/96AdulnkQhjPK\n\tNF7/TkqFHVG/bNvc5rvXiTQ55d7Kh/EFsKAYxmgsL1cOqxTeQxxfWFhftmajKEb/yu\n\t7SK7W7Lm56VXBHaWiNwQXayvGdAjZIsBhkHPXhQQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"i60IdIEm\"; dkim-atps=neutral","Date":"Thu, 21 Jul 2022 10:11:53 +0300","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<Ytj8ObA7qOENp4wc@pendragon.ideasonboard.com>","References":"<20220720081534.26400-1-naush@raspberrypi.com>\n\t<CAEmqJPr67BehwT1W71utOeHhsB4zkzWcOyoAdcWh9vX6xqK_fA@mail.gmail.com>\n\t<YtfWjDjqdVQ7v/4y@pendragon.ideasonboard.com>\n\t<CAEmqJPr2kHK93q8xf9tMBUDB6NvsPSZDXC4KmTkj8BcO-q3vew@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<CAEmqJPr2kHK93q8xf9tMBUDB6NvsPSZDXC4KmTkj8BcO-q3vew@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: controls: Suppress\n\terror message from ControlList::get()","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]