{"id":22655,"url":"https://patchwork.libcamera.org/api/1.1/patches/22655/?format=json","web_url":"https://patchwork.libcamera.org/patch/22655/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250128121352.494582-1-pobrn@protonmail.com>","date":"2025-01-28T12:13:55","name":"[RFC,v1] libcamera: controls: ControlInfo: Ensure types match","commit_ref":null,"pull_url":null,"state":"deferred","archived":false,"hash":"fb092bf792784e0204d155cd7f6ee33ba91859e5","submitter":{"id":133,"url":"https://patchwork.libcamera.org/api/1.1/people/133/?format=json","name":"Pőcze Barnabás","email":"pobrn@protonmail.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22655/mbox/","series":[{"id":4973,"url":"https://patchwork.libcamera.org/api/1.1/series/4973/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4973","date":"2025-01-28T12:13:55","name":"[RFC,v1] libcamera: controls: ControlInfo: Ensure types match","version":1,"mbox":"https://patchwork.libcamera.org/series/4973/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22655/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22655/checks/","tags":{},"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 E5B88BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 28 Jan 2025 12:14:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0D2146855D;\n\tTue, 28 Jan 2025 13:14:04 +0100 (CET)","from mail-40133.protonmail.ch (mail-40133.protonmail.ch\n\t[185.70.40.133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3466E68546\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 28 Jan 2025 13:14:02 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"ZfuvIDCN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1738066441; x=1738325641;\n\tbh=u82KG5fEujZZMu1oSRNExKevwMuypiqiDteWz6iu2ms=;\n\th=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date:\n\tSubject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector:\n\tList-Unsubscribe:List-Unsubscribe-Post;\n\tb=ZfuvIDCNulDoSvfGU029gcZDNFJWASV7AVyo8rSANPuns3rke3I5tKbrrel5oPnz/\n\txIp3hkzz7peWYE27/DWEBpTT358w8b5cnQzyrlzXvY84VfsGP/IteVa7xEDs5FdfUq\n\tMcuHyAc6E+czcyh0rJR97C1FBdaIjBisCSlVPc90OE0pbxZwVH+FPusuFgKCmy7fXn\n\tFhhsSL9w83mTbHQT6dwpLJjAWA2/f3El+Z+AS9tXniTQaGxgKtzDa3tKEWScOo+INg\n\tJje1CvNlWkyQoWkVEME3QiOK7OPDHxga5X52upbjgfdVCPnIg3qjowepgjvCLQkWyp\n\tCCbOUdqAuqJkg==","Date":"Tue, 28 Jan 2025 12:13:55 +0000","To":"libcamera-devel@lists.libcamera.org","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"[RFC PATCH v1] libcamera: controls: ControlInfo: Ensure types match","Message-ID":"<20250128121352.494582-1-pobrn@protonmail.com>","Feedback-ID":"20568564:user:proton","X-Pm-Message-ID":"1c702f71310bc5ca39656b4f24601235a73ac359","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"It is expected that the min/max/default/etc. values in a `ControlInfo`\nhave the same type. So add assertions to check that.\n\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/libcamera/controls.cpp | 22 +++++++++++++++++++++-\n 1 file changed, 21 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 70f6f6092..07f276b35 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -580,6 +580,19 @@ ControlId::ControlId(unsigned int id, const std::string &name,\n  * \\brief The Control template type T\n  */\n \n+namespace {\n+\n+bool sameShape(const ControlValue &a, const ControlValue &b)\n+{\n+\t/**\n+\t * \\todo This is a best effort approach. Without the `ControlId`\n+\t * there is no way to check if the sizes of fixed size arrays match.\n+\t */\n+\treturn a.type() == b.type() && a.isArray() == b.isArray();\n+}\n+\n+}\n+\n /**\n  * \\class ControlInfo\n  * \\brief Describe the limits of valid values for a Control\n@@ -601,6 +614,7 @@ ControlInfo::ControlInfo(const ControlValue &min,\n \t\t\t const ControlValue &def)\n \t: min_(min), max_(max), def_(def)\n {\n+\tASSERT(sameShape(min_, max_) && (def_.isNone() || sameShape(max_, def_)));\n }\n \n /**\n@@ -616,13 +630,19 @@ ControlInfo::ControlInfo(const ControlValue &min,\n ControlInfo::ControlInfo(Span<const ControlValue> values,\n \t\t\t const ControlValue &def)\n {\n+\tASSERT(!values.empty());\n+\n \tmin_ = values.front();\n \tmax_ = values.back();\n \tdef_ = !def.isNone() ? def : values.front();\n \n+\tASSERT(sameShape(min_, max_) && sameShape(max_, def_));\n+\n \tvalues_.reserve(values.size());\n-\tfor (const ControlValue &value : values)\n+\tfor (const ControlValue &value : values) {\n+\t\tASSERT(sameShape(def_, value));\n \t\tvalues_.push_back(value);\n+\t}\n }\n \n /**\n","prefixes":["RFC","v1"]}