libcamera: process: closeAllFdsExcept(): Take vector by value
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 <barnabas.pocze@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -45,7 +45,7 @@ public:
|
||||
private:
|
||||
LIBCAMERA_DISABLE_COPY_AND_MOVE(Process)
|
||||
|
||||
void closeAllFdsExcept(const std::vector<int> &fds);
|
||||
void closeAllFdsExcept(std::vector<int> v);
|
||||
int isolate();
|
||||
void died(int wstatus);
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ int Process::start(const std::string &path,
|
||||
|
||||
std::vector<int> 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<int> &fds)
|
||||
void Process::closeAllFdsExcept(std::vector<int> v)
|
||||
{
|
||||
std::vector<int> v(fds);
|
||||
sort(v.begin(), v.end());
|
||||
|
||||
ASSERT(v.empty() || v.front() >= 0);
|
||||
|
||||
Reference in New Issue
Block a user