Show a patch.

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

{
    "id": 10331,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10331/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10331/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20201104074841.21676-2-laurent.pinchart@ideasonboard.com>",
    "date": "2020-11-04T07:48:39",
    "name": "[libcamera-devel,v2,1/3] libcamera: v4l2_videodevice: Zero-initialize planes in V4L2DeviceFormat",
    "commit_ref": "2d43b8bcd8571dbce1969fa1fd50c655585f780b",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "ee1b9d532c962a564475a147b33b40c00f1dc87a",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10331/mbox/",
    "series": [
        {
            "id": 1443,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1443/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1443",
            "date": "2020-11-04T07:48:38",
            "name": "libcamera: Fix uninitialized use of V4L2DeviceFormat members",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1443/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10331/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10331/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 27567BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Nov 2020 07:49:36 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1BD9C62C74;\n\tWed,  4 Nov 2020 08:49:35 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A8E7760344\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Nov 2020 08:49:33 +0100 (CET)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 498B6BB5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Nov 2020 08:49:33 +0100 (CET)"
        ],
        "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=\"vOYY5VUf\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1604476173;\n\tbh=FFO9/3LKr9nbjjQiIH1pYvqISBGmITwX54tqboMw+Sk=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=vOYY5VUf/Sq0DgwSU8QYfHQtT67AKoFrpb6UDFFS7R0V6kH0IcuynceldZD+bUCkD\n\tfteGQXRpeE4ie8N3xM544CY3EdhAcAOolzno1AHlHLZo8/lNT7NF4B1rW7zBSskdLs\n\ty4V1kO/sNLCgKVmHAsEbRnin1U09wsAf0EimO6EI=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  4 Nov 2020 09:48:39 +0200",
        "Message-Id": "<20201104074841.21676-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20201104074841.21676-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20201104074841.21676-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 1/3] libcamera: v4l2_videodevice:\n\tZero-initialize planes in V4L2DeviceFormat",
        "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": "The V4L2DeviceFormat class doesn't have a default constructor, neither\ndoes it specifies default member initializers for the plane-related\nmembers. This results in the planes array and planesCount members being\nuninitialized by default, leading to undefined behaviour if the user of\nthe class doesn't initialize it explicitly.\n\nMost users initialize V4L2DeviceFormat instances, but some don't. We\ncould fix them, but that would likely turn into a game of whack-a-mole.\nAs there's no use case for instantiating a large number of\nV4L2DeviceFormat instances in a performance-critical code path, let's\ninstead add default initializers to avoid future issues.\n\nWhile at it, define a type of the structures containing plane\ninformation, and use an std::array.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_videodevice.h | 13 ++++++++-----\n src/libcamera/v4l2_videodevice.cpp            |  9 +++++++++\n 2 files changed, 17 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 53f6a2d5515b..dcb9654a34b8 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -7,6 +7,7 @@\n #ifndef __LIBCAMERA_INTERNAL_V4L2_VIDEODEVICE_H__\n #define __LIBCAMERA_INTERNAL_V4L2_VIDEODEVICE_H__\n \n+#include <array>\n #include <atomic>\n #include <memory>\n #include <stdint.h>\n@@ -153,14 +154,16 @@ private:\n class V4L2DeviceFormat\n {\n public:\n+\tstruct Plane {\n+\t\tuint32_t size = 0;\n+\t\tuint32_t bpl = 0;\n+\t};\n+\n \tV4L2PixelFormat fourcc;\n \tSize size;\n \n-\tstruct {\n-\t\tuint32_t size;\n-\t\tuint32_t bpl;\n-\t} planes[3];\n-\tunsigned int planesCount;\n+\tstd::array<Plane, 3> planes;\n+\tunsigned int planesCount = 0;\n \n \tconst std::string toString() const;\n };\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 36d7d9a0f27a..d07c3530eea5 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -351,6 +351,15 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const\n  * V4L2DeviceFormat::planesCount value.\n  */\n \n+/**\n+ * \\struct V4L2DeviceFormat::Plane\n+ * \\brief Per-plane memory size information\n+ * \\var V4L2DeviceFormat::Plane::size\n+ * \\brief The plane total memory size (in bytes)\n+ * \\var V4L2DeviceFormat::Plane::bpl\n+ * \\brief The plane line stride (in bytes)\n+ */\n+\n /**\n  * \\var V4L2DeviceFormat::size\n  * \\brief The image size in pixels\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "1/3"
    ]
}