Patch Detail
Show a patch.
GET /api/1.1/patches/16243/?format=api
{ "id": 16243, "url": "https://patchwork.libcamera.org/api/1.1/patches/16243/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16243/", "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": "<20220616142403.20723-8-laurent.pinchart@ideasonboard.com>", "date": "2022-06-16T14:24:03", "name": "[libcamera-devel,7/7] libcamera: yaml_parser: Add get() specializations for 16-bit integers", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e8fe0705e1817ba26c59bebfc76f8fdd9ca5db87", "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/16243/mbox/", "series": [ { "id": 3181, "url": "https://patchwork.libcamera.org/api/1.1/series/3181/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3181", "date": "2022-06-16T14:23:56", "name": "libcamera: yaml_parser: Add iterator API", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3181/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16243/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16243/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 264ABC3278\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Jun 2022 14:24:29 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1B5B6564A;\n\tThu, 16 Jun 2022 16:24:27 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA34165649\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jun 2022 16:24:22 +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 1F184415;\n\tThu, 16 Jun 2022 16:24:22 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655389468;\n\tbh=m0wL503PX9JwlUdA0hctOJ5EKRrME6YGwFemjoRVaqk=;\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=b/3KaSkm4zwdKn4i0GSUNCRXEd3l2FEqjvEhDUhAoesX/Po/PMJGRy9rrCYs2VG7S\n\tTAo+Xatxo5UaEy7Dr5OsZtI1zqRfOPJgi1oe2GiFtvFdJ/ND6JMuM9Zvtq18Su/DBD\n\ttPEeAZRxPOac5Z5TtbFwywgp987Zeeaym8/TCZw9I0PecCSU+F5OfdukeWBOAKyTfr\n\tWF/ll3MCcugaA0SeNCNBvjtWFVL/6uNJ9QTl3gqKZM4cNWpXGuQassNvC/gM8LajMB\n\t9wAsaA9tkw13MseH7CgZQKnEJb9MtarMrwcnriQ3boMYh5VVYwDd79ZZ3o1v9Tlis5\n\tnOuA9R/BIySWw==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655389462;\n\tbh=m0wL503PX9JwlUdA0hctOJ5EKRrME6YGwFemjoRVaqk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=G2WJMMJEgn3Xk3Ko68pxS2rpLILQPlqvEpBsHPkjCbEKaJsdHbnlYM5V3SBZwBdsM\n\taEIGSLSkezI6AAep5WNXZQAuhBQh649ogapeAhUja+b94c/6FvhFfOXaPe40+Qpzr0\n\tBF15zNmFeWyaefglBKE5UYWDeXb1vpOn/xHfevUE=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"G2WJMMJE\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 16 Jun 2022 17:24:03 +0300", "Message-Id": "<20220616142403.20723-8-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220616142403.20723-1-laurent.pinchart@ideasonboard.com>", "References": "<20220616142403.20723-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 7/7] libcamera: yaml_parser: Add get()\n\tspecializations 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 811be1affcc0..90d348eac74c 100644\n--- a/include/libcamera/internal/yaml_parser.h\n+++ b/include/libcamera/internal/yaml_parser.h\n@@ -156,6 +156,8 @@ public:\n \t\t typename std::enable_if_t<\n \t\t\t std::is_same_v<bool, T> ||\n \t\t\t std::is_same_v<double, T> ||\n+\t\t\t std::is_same_v<int16_t, T> ||\n+\t\t\t std::is_same_v<uint16_t, T> ||\n \t\t\t std::is_same_v<int32_t, T> ||\n \t\t\t std::is_same_v<uint32_t, T> ||\n \t\t\t std::is_same_v<std::string, T> ||\ndiff --git a/src/libcamera/yaml_parser.cpp b/src/libcamera/yaml_parser.cpp\nindex bd4b501b1422..5c45e44e49c3 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", "7/7" ] }