Patch Detail
Show a patch.
GET /api/1.1/patches/23600/?format=api
{ "id": 23600, "url": "https://patchwork.libcamera.org/api/1.1/patches/23600/?format=api", "web_url": "https://patchwork.libcamera.org/patch/23600/", "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": "<20250619093218.1335931-1-barnabas.pocze@ideasonboard.com>", "date": "2025-06-19T09:32:18", "name": "[v2] libcamera: base: bound_method: Move return value", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3b1117dc32a083958e96e84a201f4a5f0be0d4ee", "submitter": { "id": 216, "url": "https://patchwork.libcamera.org/api/1.1/people/216/?format=api", "name": "Barnabás Pőcze", "email": "barnabas.pocze@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/23600/mbox/", "series": [ { "id": 5231, "url": "https://patchwork.libcamera.org/api/1.1/series/5231/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5231", "date": "2025-06-19T09:32:18", "name": "[v2] libcamera: base: bound_method: Move return value", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5231/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/23600/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/23600/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 02189BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 19 Jun 2025 09:32:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DBFCE68DE0;\n\tThu, 19 Jun 2025 11:32:23 +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 5DDAC614E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 19 Jun 2025 11:32:22 +0200 (CEST)", "from pb-laptop.local (185.221.143.107.nat.pool.zt.hu\n\t[185.221.143.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 604479CA;\n\tThu, 19 Jun 2025 11:32:08 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Fl8mATnS\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750325528;\n\tbh=Ia1V0WxJcG2yOGR4T7Q+apof+nDricln3xlWkIqAiVI=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Fl8mATnSXuwQY4PmOnnRLPF/FM3TcpHgpwYqHxpn2hVFeOHuiVkvD/FDc/Ep553UC\n\tTr2dlusL7le8LnI4SHVCN/KOII8DvVaaqR2si697aW+xG57wqLW/EzkerGby0e1t97\n\trRTdUNdWq+bUfCr800yIJ0vYtVxSgWuCkZINw1zI=", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "Subject": "[PATCH v2] libcamera: base: bound_method: Move return value", "Date": "Thu, 19 Jun 2025 11:32:18 +0200", "Message-ID": "<20250619093218.1335931-1-barnabas.pocze@ideasonboard.com>", "X-Mailer": "git-send-email 2.50.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Instead of copying, just move the returned value when the call is made\nthrough an argument pack. This enables, e.g. `Object::invokeMethod()`\nto be usable with functions returning types, such as`std::unique_ptr`,\nthat have no copy ctor/assignment. Since there are no other users of\nthe argument pack object, this is safe to do. Reference return types\nare not supported, so a simple `std::move()` is sufficient.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=273#c1\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nchanges in v2:\n * add `[[maybe_unused]]` for gcc 9\n * review comments\n\nv1: https://patchwork.libcamera.org/patch/23598/\n---\n include/libcamera/base/bound_method.h | 21 ++++++++-------------\n test/object-invoke.cpp | 17 +++++++++++++++++\n 2 files changed, 25 insertions(+), 13 deletions(-)\n\n--\n2.50.0", "diff": "diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h\nindex 507c320d3..e14614bc4 100644\n--- a/include/libcamera/base/bound_method.h\n+++ b/include/libcamera/base/bound_method.h\n@@ -38,11 +38,6 @@ public:\n \t{\n \t}\n\n-\tR returnValue()\n-\t{\n-\t\treturn ret_;\n-\t}\n-\n \tstd::tuple<typename std::remove_reference_t<Args>...> args_;\n \tR ret_;\n };\n@@ -56,10 +51,6 @@ public:\n \t{\n \t}\n\n-\tvoid returnValue()\n-\t{\n-\t}\n-\n \tstd::tuple<typename std::remove_reference_t<Args>...> args_;\n };\n\n@@ -140,8 +131,10 @@ public:\n \t\t\treturn func_(args...);\n\n \t\tauto pack = std::make_shared<PackType>(args...);\n-\t\tbool sync = BoundMethodBase::activatePack(pack, deleteMethod);\n-\t\treturn sync ? pack->returnValue() : R();\n+\t\t[[maybe_unused]] bool sync = BoundMethodBase::activatePack(pack, deleteMethod);\n+\n+\t\tif constexpr (!std::is_void_v<R>)\n+\t\t\treturn sync ? std::move(pack->ret_) : R();\n \t}\n\n \tR invoke(Args... args) override\n@@ -175,8 +168,10 @@ public:\n \t\t}\n\n \t\tauto pack = std::make_shared<PackType>(args...);\n-\t\tbool sync = BoundMethodBase::activatePack(pack, deleteMethod);\n-\t\treturn sync ? pack->returnValue() : R();\n+\t\t[[maybe_unused]] bool sync = BoundMethodBase::activatePack(pack, deleteMethod);\n+\n+\t\tif constexpr (!std::is_void_v<R>)\n+\t\t\treturn sync ? std::move(pack->ret_) : R();\n \t}\n\n \tR invoke(Args... args) override\ndiff --git a/test/object-invoke.cpp b/test/object-invoke.cpp\nindex def1e61e4..ab4a15751 100644\n--- a/test/object-invoke.cpp\n+++ b/test/object-invoke.cpp\n@@ -58,6 +58,19 @@ public:\n \t\treturn 42;\n \t}\n\n+\tstruct MoveOnly {\n+\t\tMoveOnly() = default;\n+\t\tMoveOnly(const MoveOnly &) = delete;\n+\t\tMoveOnly &operator=(const MoveOnly &) = delete;\n+\t\tMoveOnly(MoveOnly &&) = default;\n+\t\tMoveOnly &operator=(MoveOnly &&) = default;\n+\t};\n+\n+\tMoveOnly methodWithReturnMoveOnly()\n+\t{\n+\t\treturn {};\n+\t}\n+\n private:\n \tStatus status_;\n \tint value_;\n@@ -186,6 +199,10 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n\n+\t\t/* Test invoking a method that returns type with no copy ctor/assignment. */\n+\t\tobject_.invokeMethod(&InvokedObject::methodWithReturnMoveOnly,\n+\t\t\t\t ConnectionTypeBlocking);\n+\n \t\treturn TestPass;\n \t}\n\n", "prefixes": [ "v2" ] }