Patch Detail
Show a patch.
GET /api/patches/17513/?format=api
{ "id": 17513, "url": "https://patchwork.libcamera.org/api/patches/17513/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17513/", "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": "<20221003212128.32429-4-laurent.pinchart@ideasonboard.com>", "date": "2022-10-03T21:21:23", "name": "[libcamera-devel,3/8] ipa: camera_sensor_helper: Return unique_ptr from createInstance", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "068f1ab38b55d8999284be8749b031b1c8e27f8c", "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/17513/mbox/", "series": [ { "id": 3528, "url": "https://patchwork.libcamera.org/api/series/3528/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3528", "date": "2022-10-03T21:21:20", "name": "libcamera: Use class templates for auto-registration", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3528/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17513/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17513/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 01575BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 3 Oct 2022 21:21:38 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B9260601C7;\n\tMon, 3 Oct 2022 23:21:38 +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 4EE6B60A70\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Oct 2022 23:21:36 +0200 (CEST)", "from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CBDF8440\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 3 Oct 2022 23:21:35 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664832098;\n\tbh=8NocbKuZ5437S7CzPy5r1JD5H2NzdLJnsKimXgve9OQ=;\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=Zk210YQFYHpS4PhfbO4b7Zd0qfqgsBp0TnXpODIu7vhUYcXL/+ZlyzRpn9vgMZTEV\n\t9fpbGuY5NiB1VLJ13efw3Ijv5siWrgTlNOZxVdBmE4u0bc8EXYTDCQ181i3Fjg/7MR\n\tSpYpk+hN1kLBJ5vBLu8TvZWdvb0YGtGRE8XpWJHJo2OmKHtGyZTHQkDW+i3c4VgxC8\n\t0Jxww26QyxRJYdeT/lNP1W39Ri38v1Njm3elCsKzkxhXH8C+A1ZghWijgYAFlYGtab\n\ticE0/JnHJzBBlhIyAZi6cbDpX/I1BAa4yk/QEm4w3pTO4q0UIF3HEC35NBPe1Sby9A\n\tUGLUt8vII2Kdg==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664832096;\n\tbh=8NocbKuZ5437S7CzPy5r1JD5H2NzdLJnsKimXgve9OQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=eu4M2CwL3yhFbydgaLj8BIdAVIOUNT7qkDtcUIGX6VUm3q1PDs8uLrp/2D7kxTiUo\n\tCtTz7O135/y3x74TXNfylIp1VBjzQBhOraYsf8Jrfbz3wN3bKllINPgtTcM7nuwpHe\n\tiDFKH0SV3zFdH6l1zap3Jah3Wq70FWD4DCD6Rc7Q=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"eu4M2CwL\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 4 Oct 2022 00:21:23 +0300", "Message-Id": "<20221003212128.32429-4-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20221003212128.32429-1-laurent.pinchart@ideasonboard.com>", "References": "<20221003212128.32429-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 3/8] ipa: camera_sensor_helper: Return\n\tunique_ptr from createInstance", "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": "Avoid naked pointer with memory allocation by returning a unique_ptr\nfrom CameraSensorHelperFactory::createInstance(), in order to increase\nmemory allocation safety.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/camera_sensor_helper.cpp | 7 +++----\n src/ipa/libipa/camera_sensor_helper.h | 6 +++---\n 2 files changed, 6 insertions(+), 7 deletions(-)", "diff": "diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp\nindex fde9bf5b8892..3a7d701d8616 100644\n--- a/src/ipa/libipa/camera_sensor_helper.cpp\n+++ b/src/ipa/libipa/camera_sensor_helper.cpp\n@@ -261,8 +261,7 @@ std::unique_ptr<CameraSensorHelper> CameraSensorHelperFactory::create(const std:\n \t\tif (name != factory->name_)\n \t\t\tcontinue;\n \n-\t\tCameraSensorHelper *helper = factory->createInstance();\n-\t\treturn std::unique_ptr<CameraSensorHelper>(helper);\n+\t\treturn factory->createInstance();\n \t}\n \n \treturn nullptr;\n@@ -307,8 +306,8 @@ std::vector<CameraSensorHelperFactory *> &CameraSensorHelperFactory::factories()\n * macro. It creates a camera sensor helper instance associated with the camera\n * sensor model.\n *\n- * \\return A pointer to a newly constructed instance of the CameraSensorHelper\n- * subclass corresponding to the factory\n+ * \\return A unique pointer to a newly constructed instance of the\n+ * CameraSensorHelper subclass corresponding to the factory\n */\n \n /**\ndiff --git a/src/ipa/libipa/camera_sensor_helper.h b/src/ipa/libipa/camera_sensor_helper.h\nindex 410156efb2ea..21ee43cc9f9f 100644\n--- a/src/ipa/libipa/camera_sensor_helper.h\n+++ b/src/ipa/libipa/camera_sensor_helper.h\n@@ -73,7 +73,7 @@ private:\n \n \tstatic void registerType(CameraSensorHelperFactory *factory);\n \n-\tvirtual CameraSensorHelper *createInstance() const = 0;\n+\tvirtual std::unique_ptr<CameraSensorHelper> createInstance() const = 0;\n \n \tstd::string name_;\n };\n@@ -85,9 +85,9 @@ public: \t\t\t\t\t\t\t\\\n \thelper##Factory() : CameraSensorHelperFactory(name) {}\t\\\n \t\t\t\t\t\t\t\t\\\n private:\t\t\t\t\t\t\t\\\n-\tCameraSensorHelper *createInstance() const\t\t\\\n+\tstd::unique_ptr<CameraSensorHelper> createInstance() const \\\n \t{\t\t\t\t\t\t\t\\\n-\t\treturn new helper();\t\t\t\t\\\n+\t\treturn std::make_unique<helper>();\t\t\\\n \t}\t\t\t\t\t\t\t\\\n };\t\t\t\t\t\t\t\t\\\n static helper##Factory global_##helper##Factory;\n", "prefixes": [ "libcamera-devel", "3/8" ] }