{"id":13526,"url":"https://patchwork.libcamera.org/api/patches/13526/?format=json","web_url":"https://patchwork.libcamera.org/patch/13526/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210827023829.5871-6-laurent.pinchart@ideasonboard.com>","date":"2021-08-27T02:38:28","name":"[libcamera-devel,v1,5/6] libcamera: Don't use emitter object pointer argument to slot","commit_ref":"3f662ae3c0c6e6564f1abe09d7d297e34f77b4fb","pull_url":null,"state":"accepted","archived":false,"hash":"f1d51c16540620f9cf8d764d0666269b25b1c8a3","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13526/mbox/","series":[{"id":2402,"url":"https://patchwork.libcamera.org/api/series/2402/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2402","date":"2021-08-27T02:38:23","name":"libcamera: Drop emitter object pointer from signal arguments","version":1,"mbox":"https://patchwork.libcamera.org/series/2402/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13526/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13526/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 ED46FC3243\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Aug 2021 02:38:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 78F7168951;\n\tFri, 27 Aug 2021 04:38:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7EDE868932\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Aug 2021 04:38:47 +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 2AA9A5A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Aug 2021 04:38:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"suyYIUIW\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1630031927;\n\tbh=Tp3dZB2PAoqMJo/t/PeTR6CadAqCDOBgLYqygLaTGhA=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=suyYIUIWsCBpn4kf1bUB785neLCZYuHKahV8EY2ro5TDqNt/6pFQH/kdekzsOclQ4\n\t/FDKsqc8lecVhd2xVG2Rg6Z9PDoiVt2aTYOFWCpKE6XbDxVZudwYITilSlQ5/yXWTn\n\t3wuv/cg7oKH20Cgjs3M/8Nvoj6M+RWpGZ8JDH2os=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 27 Aug 2021 05:38:28 +0300","Message-Id":"<20210827023829.5871-6-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210827023829.5871-1-laurent.pinchart@ideasonboard.com>","References":"<20210827023829.5871-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 5/6] libcamera: Don't use emitter\n\tobject pointer argument to slot","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":"In many cases, the emitter object passed as a pointer from signals to\nslots is also available as a class member. Use the class member when\nthis occurs, to prepare for removal of the emitter object pointer from\nsignals.\n\nIn test/event.cpp, this additionally requires moving the EventNotifier\nto a class member.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/ipc_pipe_unixsocket.cpp           |  4 ++--\n test/event-thread.cpp                           |  4 ++--\n test/event.cpp                                  | 17 +++++++++++------\n test/ipa/ipa_interface_test.cpp                 |  4 ++--\n test/ipc/unixsocket.cpp                         |  8 ++++----\n test/ipc/unixsocket_ipc.cpp                     |  4 ++--\n .../module_ipa_proxy_worker.cpp.tmpl            |  4 ++--\n 7 files changed, 25 insertions(+), 20 deletions(-)","diff":"diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\nindex 4511775fb467..38bcc30a21ed 100644\n--- a/src/libcamera/ipc_pipe_unixsocket.cpp\n+++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n@@ -82,10 +82,10 @@ int IPCPipeUnixSocket::sendAsync(const IPCMessage &data)\n \treturn 0;\n }\n \n-void IPCPipeUnixSocket::readyRead(IPCUnixSocket *socket)\n+void IPCPipeUnixSocket::readyRead([[maybe_unused]] IPCUnixSocket *socket)\n {\n \tIPCUnixSocket::Payload payload;\n-\tint ret = socket->receive(&payload);\n+\tint ret = socket_->receive(&payload);\n \tif (ret) {\n \t\tLOG(IPCPipe, Error) << \"Receive message failed\" << ret;\n \t\treturn;\ndiff --git a/test/event-thread.cpp b/test/event-thread.cpp\nindex 575261664c2f..12021710ef41 100644\n--- a/test/event-thread.cpp\n+++ b/test/event-thread.cpp\n@@ -66,9 +66,9 @@ public:\n \t}\n \n private:\n-\tvoid readReady(EventNotifier *notifier)\n+\tvoid readReady([[maybe_unused]] EventNotifier *notifier)\n \t{\n-\t\tsize_ = read(notifier->fd(), data_, sizeof(data_));\n+\t\tsize_ = read(notifier_->fd(), data_, sizeof(data_));\n \t\tnotified_ = true;\n \t}\n \ndiff --git a/test/event.cpp b/test/event.cpp\nindex c2274344b7f0..e338335c11e8 100644\n--- a/test/event.cpp\n+++ b/test/event.cpp\n@@ -22,14 +22,16 @@ using namespace libcamera;\n class EventTest : public Test\n {\n protected:\n-\tvoid readReady(EventNotifier *notifier)\n+\tvoid readReady([[maybe_unused]] EventNotifier *notifier)\n \t{\n-\t\tsize_ = read(notifier->fd(), data_, sizeof(data_));\n+\t\tsize_ = read(notifier_->fd(), data_, sizeof(data_));\n \t\tnotified_ = true;\n \t}\n \n \tint init()\n \t{\n+\t\tnotifier_ = nullptr;\n+\n \t\treturn pipe(pipefd_);\n \t}\n \n@@ -40,8 +42,8 @@ protected:\n \t\tTimer timeout;\n \t\tssize_t ret;\n \n-\t\tEventNotifier readNotifier(pipefd_[0], EventNotifier::Read);\n-\t\treadNotifier.activated.connect(this, &EventTest::readReady);\n+\t\tnotifier_ = new EventNotifier(pipefd_[0], EventNotifier::Read);\n+\t\tnotifier_->activated.connect(this, &EventTest::readReady);\n \n \t\t/* Test read notification with data. */\n \t\tmemset(data_, 0, sizeof(data_));\n@@ -76,7 +78,7 @@ protected:\n \n \t\t/* Test read notifier disabling. */\n \t\tnotified_ = false;\n-\t\treadNotifier.setEnabled(false);\n+\t\tnotifier_->setEnabled(false);\n \n \t\tret = write(pipefd_[1], data.data(), data.size());\n \t\tif (ret < 0) {\n@@ -95,7 +97,7 @@ protected:\n \n \t\t/* Test read notifier enabling. */\n \t\tnotified_ = false;\n-\t\treadNotifier.setEnabled(true);\n+\t\tnotifier_->setEnabled(true);\n \n \t\ttimeout.start(100);\n \t\tdispatcher->processEvents();\n@@ -111,6 +113,8 @@ protected:\n \n \tvoid cleanup()\n \t{\n+\t\tdelete notifier_;\n+\n \t\tclose(pipefd_[0]);\n \t\tclose(pipefd_[1]);\n \t}\n@@ -118,6 +122,7 @@ protected:\n private:\n \tint pipefd_[2];\n \n+\tEventNotifier *notifier_;\n \tbool notified_;\n \tchar data_[16];\n \tssize_t size_;\ndiff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp\nindex ee9f26510784..0ee51f71fd87 100644\n--- a/test/ipa/ipa_interface_test.cpp\n+++ b/test/ipa/ipa_interface_test.cpp\n@@ -153,9 +153,9 @@ protected:\n \t}\n \n private:\n-\tvoid readTrace(EventNotifier *notifier)\n+\tvoid readTrace([[maybe_unused]] EventNotifier *notifier)\n \t{\n-\t\tssize_t s = read(notifier->fd(), &trace_, sizeof(trace_));\n+\t\tssize_t s = read(notifier_->fd(), &trace_, sizeof(trace_));\n \t\tif (s < 0) {\n \t\t\tint ret = errno;\n \t\t\tcerr << \"Failed to read from IPA test FIFO at '\"\ndiff --git a/test/ipc/unixsocket.cpp b/test/ipc/unixsocket.cpp\nindex aa35c8f071f1..6507fb12d74b 100644\n--- a/test/ipc/unixsocket.cpp\n+++ b/test/ipc/unixsocket.cpp\n@@ -68,12 +68,12 @@ public:\n \t}\n \n private:\n-\tvoid readyRead(IPCUnixSocket *ipc)\n+\tvoid readyRead([[maybe_unused]] IPCUnixSocket *ipc)\n \t{\n \t\tIPCUnixSocket::Payload message, response;\n \t\tint ret;\n \n-\t\tret = ipc->receive(&message);\n+\t\tret = ipc_.receive(&message);\n \t\tif (ret) {\n \t\t\tcerr << \"Receive message failed: \" << ret << endl;\n \t\t\treturn;\n@@ -447,14 +447,14 @@ private:\n \t\treturn 0;\n \t}\n \n-\tvoid readyRead(IPCUnixSocket *ipc)\n+\tvoid readyRead([[maybe_unused]] IPCUnixSocket *ipc)\n \t{\n \t\tif (!callResponse_) {\n \t\t\tcerr << \"Read ready without expecting data, fail.\" << endl;\n \t\t\treturn;\n \t\t}\n \n-\t\tif (ipc->receive(callResponse_)) {\n+\t\tif (ipc_.receive(callResponse_)) {\n \t\t\tcerr << \"Receive message failed\" << endl;\n \t\t\treturn;\n \t\t}\ndiff --git a/test/ipc/unixsocket_ipc.cpp b/test/ipc/unixsocket_ipc.cpp\nindex 6fe7fd9b8fc5..60317a4956b8 100644\n--- a/test/ipc/unixsocket_ipc.cpp\n+++ b/test/ipc/unixsocket_ipc.cpp\n@@ -65,12 +65,12 @@ public:\n \t}\n \n private:\n-\tvoid readyRead(IPCUnixSocket *ipc)\n+\tvoid readyRead([[maybe_unused]] IPCUnixSocket *ipc)\n \t{\n \t\tIPCUnixSocket::Payload message;\n \t\tint ret;\n \n-\t\tret = ipc->receive(&message);\n+\t\tret = ipc_.receive(&message);\n \t\tif (ret) {\n \t\t\tcerr << \"Receive message failed: \" << ret << endl;\n \t\t\treturn;\ndiff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl\nindex 8a88bd467da7..b4cd1aa9e823 100644\n--- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl\n+++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl\n@@ -57,10 +57,10 @@ public:\n \n \t~{{proxy_worker_name}}() {}\n \n-\tvoid readyRead(IPCUnixSocket *socket)\n+\tvoid readyRead([[maybe_unused]] IPCUnixSocket *socket)\n \t{\n \t\tIPCUnixSocket::Payload _message;\n-\t\tint _retRecv = socket->receive(&_message);\n+\t\tint _retRecv = socket_.receive(&_message);\n \t\tif (_retRecv) {\n \t\t\tLOG({{proxy_worker_name}}, Error)\n \t\t\t\t<< \"Receive message failed: \" << _retRecv;\n","prefixes":["libcamera-devel","v1","5/6"]}