[{"id":35255,"web_url":"https://patchwork.libcamera.org/comment/35255/","msgid":"<20250730162453.GA28951@pendragon.ideasonboard.com>","date":"2025-07-30T16:24:53","subject":"Re: [PATCH v6 3/6] libcamera: process: closeAllFdsExcept(): Take\n\tvector by value","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Barnabàs,\n\nThank you for the patch.\n\nOn Mon, Jul 28, 2025 at 01:36:38PM +0200, Barnabás Pőcze wrote:\n> Instead of creating a new vector, take the vector by value to make it\n> possible for the caller to use move construction when calling the function.\n> \n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/internal/process.h | 2 +-\n>  src/libcamera/process.cpp            | 5 ++---\n>  2 files changed, 3 insertions(+), 4 deletions(-)\n> \n> diff --git a/include/libcamera/internal/process.h b/include/libcamera/internal/process.h\n> index 307c809f7..4ab846b24 100644\n> --- a/include/libcamera/internal/process.h\n> +++ b/include/libcamera/internal/process.h\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(std::vector<int> v);\n>  \tint isolate();\n>  \tvoid died(int wstatus);\n>  \n> diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp\n> index 479163e83..5193386ce 100644\n> --- a/src/libcamera/process.cpp\n> +++ b/src/libcamera/process.cpp\n> @@ -264,7 +264,7 @@ int Process::start(const std::string &path,\n>  \n>  \t\tstd::vector<int> v(fds.begin(), fds.end());\n>  \t\tv.push_back(STDERR_FILENO);\n> -\t\tcloseAllFdsExcept(v);\n> +\t\tcloseAllFdsExcept(std::move(v));\n>  \n>  \t\tconst auto tryDevNullLowestFd = [](int expected, int oflag) {\n>  \t\t\tint fd = open(\"/dev/null\", oflag);\n> @@ -296,9 +296,8 @@ int Process::start(const std::string &path,\n>  \t}\n>  }\n>  \n> -void Process::closeAllFdsExcept(const std::vector<int> &fds)\n> +void Process::closeAllFdsExcept(std::vector<int> v)\n>  {\n> -\tstd::vector<int> v(fds);\n>  \tsort(v.begin(), v.end());\n>  \n>  \tASSERT(v.empty() || v.front() >= 0);","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 53F0ABDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 30 Jul 2025 16:25:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BB5986920B;\n\tWed, 30 Jul 2025 18:25:04 +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 314416084D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Jul 2025 18:25:03 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 5782FC0B;\n\tWed, 30 Jul 2025 18:24:19 +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=\"bHD0Koln\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753892659;\n\tbh=7KsKEf4JfPtac/3CBRquerL4rHq8yV+VXZU0r57vYoE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bHD0KolnsnqyzctRl4LgF/Zw8KNi7+mTCrgZwGYo1a+/HDynSa6wGhdIIAofmSsnH\n\t+2rorzGnDyJ+XETS7j5AcIw8Mnhlo6ZLdR1Ga0vpHneIL9LSBfxTKF7hEKWEAGhRMh\n\t29HXifWh4Vch4XPaEfQpTpXB/VIfjh1A7QrveDpc=","Date":"Wed, 30 Jul 2025 19:24:53 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v6 3/6] libcamera: process: closeAllFdsExcept(): Take\n\tvector by value","Message-ID":"<20250730162453.GA28951@pendragon.ideasonboard.com>","References":"<20250728113641.238256-1-barnabas.pocze@ideasonboard.com>\n\t<20250728113641.238256-4-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20250728113641.238256-4-barnabas.pocze@ideasonboard.com>","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>"}}]