{"id":23248,"url":"https://patchwork.libcamera.org/api/patches/23248/?format=json","web_url":"https://patchwork.libcamera.org/patch/23248/","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":"<20250424112203.445351-7-barnabas.pocze@ideasonboard.com>","date":"2025-04-24T11:21:59","name":"[RFC,v4,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/23248/mbox/","series":[{"id":5144,"url":"https://patchwork.libcamera.org/api/series/5144/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5144","date":"2025-04-24T11:21:53","name":"libcamera: process: Remove `ProcessManager` singleton","version":4,"mbox":"https://patchwork.libcamera.org/series/5144/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23248/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23248/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 A317BC3321\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Apr 2025 11:22:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2632468B2B;\n\tThu, 24 Apr 2025 13:22:19 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E96168AD3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Apr 2025 13:22:08 +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 95C9D18E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Apr 2025 13:22: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=\"VEffDEwO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1745493726;\n\tbh=MZl7tDpA6SRqfheZTd2QqlxmlX3SfZjKHJ+upIArxSs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=VEffDEwODvyvrj8FlJSsvoMLawVf7OYLyrbuioc4G0z3AXl9n3gCRVDzi6OH7W05c\n\t1z0/F+ctFe0SWsgbI04LGcWRXngXGqXj892IEtOFilp4MrXjuF1ZvROjYfJHkAZKgc\n\tUtmrkUgKbSsRhxBTzXQ6fdCFLXA4DI922H2flhgM=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[RFC PATCH v4 6/9] libcamera: process: Use span instead of vector","Date":"Thu, 24 Apr 2025 13:21:59 +0200","Message-ID":"<20250424112203.445351-7-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<20250424112203.445351-1-barnabas.pocze@ideasonboard.com>","References":"<20250424112203.445351-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>\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","v4","6/9"]}