Patch Detail
Show a patch.
GET /api/patches/12088/?format=api
{ "id": 12088, "url": "https://patchwork.libcamera.org/api/patches/12088/?format=api", "web_url": "https://patchwork.libcamera.org/patch/12088/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20210423020932.2760-4-laurent.pinchart@ideasonboard.com>", "date": "2021-04-23T02:09:32", "name": "[libcamera-devel,PATCH/RFC,3/3] v4l2: Replace manual loop counters with utils::enumerate()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "fccdc97877dfd5f5ae956acae9911dcbd0d02b66", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": { "id": 14, "url": "https://patchwork.libcamera.org/api/users/14/?format=api", "username": "pinchartl", "first_name": "Laurent", "last_name": "Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "mbox": "https://patchwork.libcamera.org/patch/12088/mbox/", "series": [ { "id": 1966, "url": "https://patchwork.libcamera.org/api/series/1966/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1966", "date": "2021-04-23T02:09:29", "name": "libcamera: Simplify range-based for loop counters", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1966/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/12088/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/12088/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 C5C13BDB8F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Apr 2021 02:09:47 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AB74568877;\n\tFri, 23 Apr 2021 04:09:46 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2614568861\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Apr 2021 04:09:42 +0200 (CEST)", "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B931545F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Apr 2021 04:09:41 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Xiw0AKSq\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1619143781;\n\tbh=HGOQ6/6vWJ8+ScThuZGR2JWwmRkiuuAFjroHr/hHJr8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Xiw0AKSqLC6OfkY/13jFr67Tr5B/hu9EXg/G8pauetF9EFOukaLhpfo8BWNg8BhtV\n\tq8MsPeHdCr1peHmSEnedVBYqyZ+PuLApqv/MqQYHjK1vLRL9NhoK+pq1RHRV2xcItU\n\t5gmQ25bKzwwF81APaDpIGT+Zm+aQ0dBGf2fEo2fk=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 23 Apr 2021 05:09:32 +0300", "Message-Id": "<20210423020932.2760-4-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.28.1", "In-Reply-To": "<20210423020932.2760-1-laurent.pinchart@ideasonboard.com>", "References": "<20210423020932.2760-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH/RFC 3/3] v4l2: Replace manual loop\n\tcounters with utils::enumerate()", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Use the newly introduced utils::enumerate() to replace manual loop\ncounters. A local variable is needed, as utils::enumerate() requires an\nlvalue reference.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/v4l2/v4l2_compat_manager.cpp | 18 +++++++++---------\n 1 file changed, 9 insertions(+), 9 deletions(-)", "diff": "diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\nindex 90c0f0121a32..bf5bf8e3223d 100644\n--- a/src/v4l2/v4l2_compat_manager.cpp\n+++ b/src/v4l2/v4l2_compat_manager.cpp\n@@ -23,6 +23,7 @@\n #include <libcamera/camera_manager.h>\n \n #include \"libcamera/internal/log.h\"\n+#include \"libcamera/internal/utils.h\"\n \n #include \"v4l2_camera_file.h\"\n \n@@ -81,11 +82,11 @@ int V4L2CompatManager::start()\n \t * For each Camera registered in the system, a V4L2CameraProxy gets\n \t * created here to wrap a camera device.\n \t */\n-\tunsigned int index = 0;\n-\tfor (auto &camera : cm_->cameras()) {\n-\t\tV4L2CameraProxy *proxy = new V4L2CameraProxy(index, camera);\n+\tauto cameras = cm_->cameras();\n+\tfor (const auto camera : utils::enumerate(cameras)) {\n+\t\tV4L2CameraProxy *proxy = new V4L2CameraProxy(camera.index,\n+\t\t\t\t\t\t\t camera.value);\n \t\tproxies_.emplace_back(proxy);\n-\t\t++index;\n \t}\n \n \treturn 0;\n@@ -117,11 +118,10 @@ int V4L2CompatManager::getCameraIndex(int fd)\n \tif (!target)\n \t\treturn -1;\n \n-\tunsigned int index = 0;\n-\tfor (auto &camera : cm_->cameras()) {\n-\t\tif (camera == target)\n-\t\t\treturn index;\n-\t\t++index;\n+\tauto cameras = cm_->cameras();\n+\tfor (const auto camera : utils::enumerate(cameras)) {\n+\t\tif (camera.value == target)\n+\t\t\treturn camera.index;\n \t}\n \n \treturn -1;\n", "prefixes": [ "libcamera-devel", "PATCH/RFC", "3/3" ] }