{"id":23107,"url":"https://patchwork.libcamera.org/api/1.1/patches/23107/?format=json","web_url":"https://patchwork.libcamera.org/patch/23107/","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":"<20250402115010.937137-1-barnabas.pocze@ideasonboard.com>","date":"2025-04-02T11:50:10","name":"[v1] libcamera: controls: Fix `ControlInfoMap::count(unsigned int)`","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"792110a452eaa6cd7adf9e02e999234bbea4e686","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23107/mbox/","series":[{"id":5107,"url":"https://patchwork.libcamera.org/api/1.1/series/5107/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5107","date":"2025-04-02T11:50:10","name":"[v1] libcamera: controls: Fix `ControlInfoMap::count(unsigned int)`","version":1,"mbox":"https://patchwork.libcamera.org/series/5107/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23107/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23107/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 BBBE8C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Apr 2025 11:50:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8174F68985;\n\tWed,  2 Apr 2025 13:50:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B18168979\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 13:50:17 +0200 (CEST)","from pb-laptop.local (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C079F6A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 13:48:24 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XqbzXMxV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743594504;\n\tbh=KjLu3jU0ANnTnaFWpdyKCq9IGZtLk2iYgrIt8kBH2jY=;\n\th=From:To:Subject:Date:From;\n\tb=XqbzXMxVs9StsQ0xdcZL1TMqGw8svHoTWyCO7CZ3gVv+TUlCZb0fiL6GgTwxAtH/j\n\teJAmXjxByfZmsRQRjRRB42cj2HqNxLp0f1jYeEwl3coiQWiVoPXHQ7ZHEU/Qpg9nfA\n\t3ggixeK2Uqi6yDyG1vM6JFZ0bCtIdfARjzhq94Sg=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v1] libcamera: controls: Fix `ControlInfoMap::count(unsigned\n\tint)`","Date":"Wed,  2 Apr 2025 13:50:10 +0200","Message-ID":"<20250402115010.937137-1-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.49.0","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","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":"The two overloads of `find()` and `at()` have the same behaviour\nregardless of the argument type: `unsigned int` or `const ControlId *`.\nHowever, `count()` is not so because `count(unsigned int)` only checks\nthe `ControlIdMap`, and it does not check if the given id is actually\npresent in the map storing the `ControlInfo` objects.\n\nSo `count()` returns 1 for every control id that is present in the\nassociated `ControlIdMap` regardless of whether there is an actual\nentry for the `ControlId` associated with the given numeric id.\n\nFix that by simply using `find()` to determine the return value.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/controls.cpp | 10 +---------\n 1 file changed, 1 insertion(+), 9 deletions(-)","diff":"diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 70f6f6092..98fa7583d 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -857,15 +857,7 @@ const ControlInfoMap::mapped_type &ControlInfoMap::at(unsigned int id) const\n  */\n ControlInfoMap::size_type ControlInfoMap::count(unsigned int id) const\n {\n-\tif (!idmap_)\n-\t\treturn 0;\n-\n-\t/*\n-\t * The ControlInfoMap and its idmap have a 1:1 mapping between their\n-\t * entries, we can thus just count the matching entries in idmap to\n-\t * avoid an additional lookup.\n-\t */\n-\treturn idmap_->count(id);\n+\treturn find(id) != end();\n }\n \n /**\n","prefixes":["v1"]}