Show a patch.

GET /api/patches/12300/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 12300,
    "url": "https://patchwork.libcamera.org/api/patches/12300/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12300/",
    "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": "<20210515040511.23294-3-laurent.pinchart@ideasonboard.com>",
    "date": "2021-05-15T04:05:09",
    "name": "[libcamera-devel,v2,2/4] v4l2: Replace manual loop counters with utils::enumerate()",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a767c2fff9f3a17590e1c72b233bbbf9fa993cbf",
    "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/12300/mbox/",
    "series": [
        {
            "id": 2032,
            "url": "https://patchwork.libcamera.org/api/series/2032/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2032",
            "date": "2021-05-15T04:05:07",
            "name": "libcamera: Simplify range-based for loop counters",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2032/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12300/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12300/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 4BF42C31F6\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 15 May 2021 04:05:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 086C16891B;\n\tSat, 15 May 2021 06:05:31 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 528EC6890E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 15 May 2021 06:05:26 +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 C56326EE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 15 May 2021 06:05:25 +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=\"geQXy/77\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621051525;\n\tbh=2QFRSWUCMAfsZ+kMhZHJISQfTSzuMpk9atCohxy2mvY=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=geQXy/77hkrYnlb4jkbTUaaq2XM9miRWbgB842HmAGO+4xKvLcVmeQgpDnXX/RJTp\n\tjN5HyIi5cuK8OyaMdqksPQWh0CgfUAFLMoOLNCterZI8IXH68n+dNhHjQwuIbIZz8U\n\tZyzRhS76xpfnkKEYvRjCteWXoEe5Q7OWKRP5cs/U=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sat, 15 May 2021 07:05:09 +0300",
        "Message-Id": "<20210515040511.23294-3-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.28.1",
        "In-Reply-To": "<20210515040511.23294-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210515040511.23294-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 2/4] v4l2: Replace manual loop counters\n\twith 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---\nChanges since v1:\n\n- Use structured bindings\n---\n src/v4l2/v4l2_compat_manager.cpp | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)",
    "diff": "diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp\nindex 90c0f0121a32..96dbcdf28f04 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,10 @@ 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+\tauto cameras = cm_->cameras();\n+\tfor (auto [index, camera] : utils::enumerate(cameras)) {\n \t\tV4L2CameraProxy *proxy = new V4L2CameraProxy(index, camera);\n \t\tproxies_.emplace_back(proxy);\n-\t\t++index;\n \t}\n \n \treturn 0;\n@@ -117,11 +117,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+\tauto cameras = cm_->cameras();\n+\tfor (auto [index, camera] : utils::enumerate(cameras)) {\n \t\tif (camera == target)\n \t\t\treturn index;\n-\t\t++index;\n \t}\n \n \treturn -1;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "2/4"
    ]
}