Show a patch.

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

{
    "id": 2982,
    "url": "https://patchwork.libcamera.org/api/patches/2982/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2982/",
    "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": "<20200306160002.30549-11-laurent.pinchart@ideasonboard.com>",
    "date": "2020-03-06T15:59:40",
    "name": "[libcamera-devel,v2,10/32] libcamera: controls: Return control by value",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "8d959c901a113e4822ab1b4a7f6dae0064893985",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2982/mbox/",
    "series": [
        {
            "id": 703,
            "url": "https://patchwork.libcamera.org/api/series/703/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=703",
            "date": "2020-03-06T15:59:30",
            "name": "libcamera: Add support for array controls",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/703/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2982/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2982/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C4E360424\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Mar 2020 17:00:19 +0100 (CET)",
            "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B6CA01265\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Mar 2020 17:00:18 +0100 (CET)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1583510418;\n\tbh=nEdJ49LSrpFJqAxFCHbW0A2W1vUawQAGfPF7GPyRiTw=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=hPfxcm+xOo1zYT1bzdlilmF7oQFaSIeBB31tz3FCc+AnKWSTeuPIOJLGfBvBrSiEV\n\tHaB4D7Eulb/TuR7zhdx8nlApxbwFjyokIlaICRxgEAjPSzOlzE88n6WSIYS7KTb+mc\n\tdyZXtISP7mXZm5EX0roHLW+OMWNMm8nrO/mq4O2Q=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Fri,  6 Mar 2020 17:59:40 +0200",
        "Message-Id": "<20200306160002.30549-11-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 10/32] libcamera: controls: Return\n\tcontrol by value",
        "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>",
        "X-List-Received-Date": "Fri, 06 Mar 2020 16:00:19 -0000"
    },
    "content": "The ControlList::get() and ControlValue::get() methods return the\ncontrol value by reference. This requires the ControlValue class to\nstore the control value in the same form as the one returned by those\nfunctions. For the array controls that are soon to be added, the\nControlValue class would need to store a span<> instance in addition to\nthe control value itself, which would increase the required storage\nspace.\n\nPrepare for support of array controls by returning from get() by value.\nAs all control values are 8 bytes at most, this doesn't affect\nefficiency negatively.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/controls.h | 10 ++++------\n src/libcamera/controls.cpp   | 10 +++++-----\n 2 files changed, 9 insertions(+), 11 deletions(-)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 9d93064c11b2..3b6b231c7c64 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -42,7 +42,7 @@ public:\n \t}\n \n \ttemplate<typename T>\n-\tconst T &get() const;\n+\tT get() const;\n \ttemplate<typename T>\n \tvoid set(const T &value);\n \n@@ -212,13 +212,11 @@ public:\n \tbool contains(unsigned int id) const;\n \n \ttemplate<typename T>\n-\tconst T &get(const Control<T> &ctrl) const\n+\tT get(const Control<T> &ctrl) const\n \t{\n \t\tconst ControlValue *val = find(ctrl.id());\n-\t\tif (!val) {\n-\t\t\tstatic T t(0);\n-\t\t\treturn t;\n-\t\t}\n+\t\tif (!val)\n+\t\t\treturn T{};\n \n \t\treturn val->get<T>();\n \t}\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex a136ebd2653b..6a0d66fbea8d 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -160,7 +160,7 @@ bool ControlValue::operator==(const ControlValue &other) const\n  */\n \n /**\n- * \\fn template<typename T> const T &ControlValue::get() const\n+ * \\fn template<typename T> T ControlValue::get() const\n  * \\brief Get the control value\n  *\n  * The control value type shall match the type T, otherwise the behaviour is\n@@ -177,7 +177,7 @@ bool ControlValue::operator==(const ControlValue &other) const\n \n #ifndef __DOXYGEN__\n template<>\n-const bool &ControlValue::get<bool>() const\n+bool ControlValue::get<bool>() const\n {\n \tASSERT(type_ == ControlTypeBool);\n \n@@ -185,7 +185,7 @@ const bool &ControlValue::get<bool>() const\n }\n \n template<>\n-const int32_t &ControlValue::get<int32_t>() const\n+int32_t ControlValue::get<int32_t>() const\n {\n \tASSERT(type_ == ControlTypeInteger32);\n \n@@ -193,7 +193,7 @@ const int32_t &ControlValue::get<int32_t>() const\n }\n \n template<>\n-const int64_t &ControlValue::get<int64_t>() const\n+int64_t ControlValue::get<int64_t>() const\n {\n \tASSERT(type_ == ControlTypeInteger64);\n \n@@ -720,7 +720,7 @@ bool ControlList::contains(unsigned int id) const\n }\n \n /**\n- * \\fn template<typename T> const T &ControlList::get(const Control<T> &ctrl) const\n+ * \\fn template<typename T> T ControlList::get(const Control<T> &ctrl) const\n  * \\brief Get the value of control \\a ctrl\n  * \\param[in] ctrl The control\n  *\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "10/32"
    ]
}