{"id":23258,"url":"https://patchwork.libcamera.org/api/patches/23258/?format=json","web_url":"https://patchwork.libcamera.org/patch/23258/","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":"<20250424114103.451395-7-barnabas.pocze@ideasonboard.com>","date":"2025-04-24T11:41:00","name":"[RFC,v5,6/9] libcamera: process: Use span instead of vector","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"702cec31b17909ab2132e1541b84ed5df132f949","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23258/mbox/","series":[{"id":5145,"url":"https://patchwork.libcamera.org/api/series/5145/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5145","date":"2025-04-24T11:40:54","name":"libcamera: process: Remove `ProcessManager` singleton","version":5,"mbox":"https://patchwork.libcamera.org/series/5145/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23258/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23258/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 49F4CC3320\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Apr 2025 11:41:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 56DDF68B25;\n\tThu, 24 Apr 2025 13:41:16 +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 52AFB68AD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Apr 2025 13:41:09 +0200 (CEST)","from pb-laptop.local (185.221.143.16.nat.pool.zt.hu\n\t[185.221.143.16])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DC32219BF;\n\tThu, 24 Apr 2025 13:41:06 +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=\"F4c1fWQO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1745494867;\n\tbh=sGQU65lJ1MeDo8vv5WS07r8IYOXw2o/eIvT6X28zCLM=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=F4c1fWQOnQuCLAgDBjy9/PkQ885VZgqR1v4o/KpHWMfDffD5yMJ1/bem0D6NhghgT\n\tUeoOVO/cGSI+lMy3tpTIsGcufbPhWpAU6SZr6x1S0OQ3rygKHDG2XqF+RnjcsG3/tJ\n\t3FcVKHJkjQj3tIlT3j1golhSGS6JRaauhE7A/LOM=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Kieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"[RFC PATCH v5 6/9] libcamera: process: Use span instead of vector","Date":"Thu, 24 Apr 2025 13:41:00 +0200","Message-ID":"<20250424114103.451395-7-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<20250424114103.451395-1-barnabas.pocze@ideasonboard.com>","References":"<20250424114103.451395-1-barnabas.pocze@ideasonboard.com>","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":"Use `libcamera::Span` whenever applicable.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/process.h  | 8 ++++----\n src/libcamera/ipc_pipe_unixsocket.cpp | 9 +++------\n src/libcamera/process.cpp             | 8 ++++----\n test/process/process_test.cpp         | 5 ++---\n 4 files changed, 13 insertions(+), 17 deletions(-)","diff":"diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h\nindex 891e78947..b8eb7e043 100644\n--- a/include/libcamera/internal/process.h\n+++ b/include/libcamera/internal/process.h\n@@ -9,10 +9,10 @@\n \n #include <signal.h>\n #include <string>\n-#include <vector>\n \n #include <libcamera/base/class.h>\n #include <libcamera/base/signal.h>\n+#include <libcamera/base/span.h>\n #include <libcamera/base/unique_fd.h>\n \n namespace libcamera {\n@@ -32,8 +32,8 @@ public:\n \t~Process();\n \n \tint start(const std::string &path,\n-\t\t  const std::vector<std::string> &args = std::vector<std::string>(),\n-\t\t  const std::vector<int> &fds = std::vector<int>());\n+\t\t  Span<const std::string> args = {},\n+\t\t  Span<const int> fds = {});\n \n \tExitStatus exitStatus() const { return exitStatus_; }\n \tint exitCode() const { return exitCode_; }\n@@ -45,7 +45,7 @@ public:\n private:\n \tLIBCAMERA_DISABLE_COPY_AND_MOVE(Process)\n \n-\tvoid closeAllFdsExcept(const std::vector<int> &fds);\n+\tvoid closeAllFdsExcept(Span<const int> fds);\n \tint isolate();\n \tvoid died(int wstatus);\n \ndiff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp\nindex 668ec73b9..7ee7cac79 100644\n--- a/src/libcamera/ipc_pipe_unixsocket.cpp\n+++ b/src/libcamera/ipc_pipe_unixsocket.cpp\n@@ -28,10 +28,6 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,\n \t\t\t\t     const char *ipaProxyWorkerPath)\n \t: IPCPipe()\n {\n-\tstd::vector<int> fds;\n-\tstd::vector<std::string> args;\n-\targs.push_back(ipaModulePath);\n-\n \tsocket_ = std::make_unique<IPCUnixSocket>();\n \tUniqueFD fd = socket_->create();\n \tif (!fd.isValid()) {\n@@ -39,8 +35,9 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,\n \t\treturn;\n \t}\n \tsocket_->readyRead.connect(this, &IPCPipeUnixSocket::readyRead);\n-\targs.push_back(std::to_string(fd.get()));\n-\tfds.push_back(fd.get());\n+\n+\tstd::array args{ std::string(ipaModulePath), std::to_string(fd.get()) };\n+\tstd::array fds{ fd.get() };\n \n \tproc_ = std::make_unique<Process>();\n \tint ret = proc_->start(ipaProxyWorkerPath, args, fds);\ndiff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\nindex 1bc7a7f9a..99bc3ad36 100644\n--- a/src/libcamera/process.cpp\n+++ b/src/libcamera/process.cpp\n@@ -235,8 +235,8 @@ Process::~Process()\n  * or a negative error code otherwise\n  */\n int Process::start(const std::string &path,\n-\t\t   const std::vector<std::string> &args,\n-\t\t   const std::vector<int> &fds)\n+\t\t   Span<const std::string> args,\n+\t\t   Span<const int> fds)\n {\n \tint ret;\n \n@@ -282,9 +282,9 @@ int Process::start(const std::string &path,\n \t}\n }\n \n-void Process::closeAllFdsExcept(const std::vector<int> &fds)\n+void Process::closeAllFdsExcept(Span<const int> fds)\n {\n-\tstd::vector<int> v(fds);\n+\tstd::vector<int> v(fds.begin(), fds.end());\n \tsort(v.begin(), v.end());\n \n \tASSERT(v.empty() || v.front() >= 0);\ndiff --git a/test/process/process_test.cpp b/test/process/process_test.cpp\nindex e9f5e7e9b..a88d8fef1 100644\n--- a/test/process/process_test.cpp\n+++ b/test/process/process_test.cpp\n@@ -5,9 +5,9 @@\n  * Process test\n  */\n \n+#include <array>\n #include <iostream>\n #include <unistd.h>\n-#include <vector>\n \n #include <libcamera/base/event_dispatcher.h>\n #include <libcamera/base/thread.h>\n@@ -48,8 +48,7 @@ protected:\n \t\tTimer timeout;\n \n \t\tint exitCode = 42;\n-\t\tvector<std::string> args;\n-\t\targs.push_back(to_string(exitCode));\n+\t\tstd::array args{ to_string(exitCode) };\n \t\tproc_.finished.connect(this, &ProcessTest::procFinished);\n \n \t\t/* Test that kill() on an unstarted process is safe. */\n","prefixes":["RFC","v5","6/9"]}