libcamera: process: start(): Use span instead of vector
Use a span instead of a const reference to a vector, this does not change the behaviour and allows e.g. arrays to be used to hold arguments/file descriptors. Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
@@ -28,10 +28,6 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,
|
||||
const char *ipaProxyWorkerPath)
|
||||
: IPCPipe()
|
||||
{
|
||||
std::vector<int> fds;
|
||||
std::vector<std::string> args;
|
||||
args.push_back(ipaModulePath);
|
||||
|
||||
socket_ = std::make_unique<IPCUnixSocket>();
|
||||
UniqueFD fd = socket_->create();
|
||||
if (!fd.isValid()) {
|
||||
@@ -39,8 +35,9 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,
|
||||
return;
|
||||
}
|
||||
socket_->readyRead.connect(this, &IPCPipeUnixSocket::readyRead);
|
||||
args.push_back(std::to_string(fd.get()));
|
||||
fds.push_back(fd.get());
|
||||
|
||||
std::array args{ std::string(ipaModulePath), std::to_string(fd.get()) };
|
||||
std::array fds{ fd.get() };
|
||||
|
||||
proc_ = std::make_unique<Process>();
|
||||
int ret = proc_->start(ipaProxyWorkerPath, args, fds);
|
||||
|
||||
@@ -235,8 +235,8 @@ Process::~Process()
|
||||
* or a negative error code otherwise
|
||||
*/
|
||||
int Process::start(const std::string &path,
|
||||
const std::vector<std::string> &args,
|
||||
const std::vector<int> &fds)
|
||||
Span<const std::string> args,
|
||||
Span<const int> fds)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -262,7 +262,7 @@ int Process::start(const std::string &path,
|
||||
if (isolate())
|
||||
_exit(EXIT_FAILURE);
|
||||
|
||||
std::vector<int> v(fds);
|
||||
std::vector<int> v(fds.begin(), fds.end());
|
||||
v.push_back(STDERR_FILENO);
|
||||
closeAllFdsExcept(v);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user