Show a patch.

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

{
    "id": 16036,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16036/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16036/",
    "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": "<20220524225816.6830-11-laurent.pinchart@ideasonboard.com>",
    "date": "2022-05-24T22:58:14",
    "name": "[libcamera-devel,RFC,10/12] libcamera: yaml_parser: Add get() specializations for 16-bit integers",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6cc7fccb79f966700e8ede3057bf52a8ebac229d",
    "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/16036/mbox/",
    "series": [
        {
            "id": 3135,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3135/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3135",
            "date": "2022-05-24T22:58:04",
            "name": "Replace boost JSON parser with libyaml in Raspberry Pi IPA",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3135/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16036/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16036/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 C93C0C326F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 May 2022 22:58:41 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A09496566D;\n\tWed, 25 May 2022 00:58:39 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E27265674\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 May 2022 00:58:30 +0200 (CEST)",
            "from pendragon.ideasonboard.com (ip-109-40-241-133.web.vodafone.de\n\t[109.40.241.133])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D5693A58;\n\tWed, 25 May 2022 00:58:29 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653433119;\n\tbh=jAs5MXsa9CbCjWdFhEKz7i6feQcOFMCR3aVzCVIcSWU=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=QlsAxkiboHb5WORUtCCSF8LjEBsCaCZiNYOVbNKlRhjXtlwsYPIvS9aGNJOb/r0bV\n\t0MlfES6S73zHF1qNOdi/nr0UThPzpSQH++Z0Q/cPu/G7ow72HndEpAXr0ip9Eu4WPu\n\tBd96kfRitgiB51zsYefDZQQoq31+Qu4OpT6VHgICCuUoyV5vjhwEFVCwP3KyZW/NfK\n\tUrHhirinf1NwxOUqjBCBjcaAbiPQAB48R/wwJ8kuXvvQa/J9HdAqY88vPrXEcaOQ9/\n\tyjtB25/SW9GhoulgO0Tw+D9vFtRRGVcRNY/uenAtKSWJJYVZi9yvbypRDZBbrOOLWo\n\tubXwzcYv9nw1A==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653433110;\n\tbh=jAs5MXsa9CbCjWdFhEKz7i6feQcOFMCR3aVzCVIcSWU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=RzEepIhTrERlSZEgQKAdZ9xFpfiwOgbw3RrhUEhV97v6Xv8SXfNIoteAwIxLqK1rz\n\tGNRoU9bluIksVy756vkTEGUzaw1KDFB/O826sg5WRbucPm9vxRZEIwLGKY57CiOYtU\n\tZ7p/xGs3ykNbUOOFj/9FmaQ+ie8HsMaVYSuEYJtE="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"RzEepIhT\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 25 May 2022 01:58:14 +0300",
        "Message-Id": "<20220524225816.6830-11-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.35.1",
        "In-Reply-To": "<20220524225816.6830-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20220524225816.6830-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [RFC PATCH 10/12] libcamera: yaml_parser: Add\n\tget() specializations for 16-bit integers",
        "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>",
        "From": "Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Extend the YamlObject::get() function template to support 16-bit\nintegers.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/yaml_parser.h |  2 +\n src/libcamera/yaml_parser.cpp            | 61 ++++++++++++++++++++++++\n 2 files changed, 63 insertions(+)",
    "diff": "diff --git a/include/libcamera/internal/yaml_parser.h b/include/libcamera/internal/yaml_parser.h\nindex 79537ff2ea7c..dd543a138af5 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -154,6 +154,8 @@ public:\n \t\t typename std::enable_if_t<\n \t\t\t std::is_same<bool, T>::value ||\n \t\t\t std::is_same<double, T>::value ||\n+\t\t\t std::is_same<int16_t, T>::value ||\n+\t\t\t std::is_same<uint16_t, T>::value ||\n \t\t\t std::is_same<int32_t, T>::value ||\n \t\t\t std::is_same<uint32_t, T>::value ||\n \t\t\t std::is_same<std::string, T>::value ||\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex f0b5eb96449b..57e8b52965e8 100644\n--- a/src/libcamera/yaml_parser.cpp\n+++ b/src/libcamera/yaml_parser.cpp\n@@ -138,6 +138,67 @@ bool YamlObject::get(const bool &defaultValue, bool *ok) const\n \treturn defaultValue;\n }\n \n+template<>\n+int16_t YamlObject::get(const int16_t &defaultValue, bool *ok) const\n+{\n+\tsetOk(ok, false);\n+\n+\tif (type_ != Type::Value)\n+\t\treturn defaultValue;\n+\n+\tif (value_ == \"\")\n+\t\treturn defaultValue;\n+\n+\tchar *end;\n+\n+\terrno = 0;\n+\tint16_t value = std::strtol(value_.c_str(), &end, 10);\n+\n+\tif ('\\0' != *end || errno == ERANGE ||\n+\t    value < std::numeric_limits<int16_t>::min() ||\n+\t    value > std::numeric_limits<int16_t>::max())\n+\t\treturn defaultValue;\n+\n+\tsetOk(ok, true);\n+\treturn value;\n+}\n+\n+template<>\n+uint16_t YamlObject::get(const uint16_t &defaultValue, bool *ok) const\n+{\n+\tsetOk(ok, false);\n+\n+\tif (type_ != Type::Value)\n+\t\treturn defaultValue;\n+\n+\tif (value_ == \"\")\n+\t\treturn defaultValue;\n+\n+\t/*\n+\t * libyaml parses all scalar values as strings. When a string has\n+\t * leading spaces before a minus sign, for example \"  -10\", strtoul\n+\t * skips leading spaces, accepts the leading minus sign, and the\n+\t * calculated digits are negated as if by unary minus. Rule it out in\n+\t * case the user gets a large number when the value is negative.\n+\t */\n+\tstd::size_t found = value_.find_first_not_of(\" \\t\");\n+\tif (found != std::string::npos && value_[found] == '-')\n+\t\treturn defaultValue;\n+\n+\tchar *end;\n+\n+\terrno = 0;\n+\tuint16_t value = std::strtoul(value_.c_str(), &end, 10);\n+\n+\tif ('\\0' != *end || errno == ERANGE ||\n+\t    value < std::numeric_limits<uint16_t>::min() ||\n+\t    value > std::numeric_limits<uint16_t>::max())\n+\t\treturn defaultValue;\n+\n+\tsetOk(ok, true);\n+\treturn value;\n+}\n+\n template<>\n int32_t YamlObject::get(const int32_t &defaultValue, bool *ok) const\n {\n",
    "prefixes": [
        "libcamera-devel",
        "RFC",
        "10/12"
    ]
}