From b43691af949755f5efe42582dc166a8148164c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 24 Apr 2025 11:19:08 +0200 Subject: [PATCH] libcamera: process: closeAllFdsExcept(): Take vector by value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of creating a new vector, take the vector by value to make it possible for the caller to use move construction when calling the function. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- include/libcamera/internal/process.h | 2 +- src/libcamera/process.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h index 307c809f..4ab846b2 100644 --- a/include/libcamera/internal/process.h +++ b/include/libcamera/internal/process.h @@ -45,7 +45,7 @@ public: private: LIBCAMERA_DISABLE_COPY_AND_MOVE(Process) - void closeAllFdsExcept(const std::vector &fds); + void closeAllFdsExcept(std::vector v); int isolate(); void died(int wstatus); diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index 479163e8..5193386c 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -264,7 +264,7 @@ int Process::start(const std::string &path, std::vector v(fds.begin(), fds.end()); v.push_back(STDERR_FILENO); - closeAllFdsExcept(v); + closeAllFdsExcept(std::move(v)); const auto tryDevNullLowestFd = [](int expected, int oflag) { int fd = open("/dev/null", oflag); @@ -296,9 +296,8 @@ int Process::start(const std::string &path, } } -void Process::closeAllFdsExcept(const std::vector &fds) +void Process::closeAllFdsExcept(std::vector v) { - std::vector v(fds); sort(v.begin(), v.end()); ASSERT(v.empty() || v.front() >= 0);