summaryrefslogtreecommitdiff
path: root/src/libcamera/ipc_pipe_unixsocket.cpp
diff options
context:
space:
mode:
authorHirokazu Honda <hiroh@chromium.org>2021-06-10 16:50:25 +0900
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-04 23:05:03 +0200
commit91436688874a2450c7da22527c59e34c2053b9ef (patch)
treed7220d238db08c90ab37f990a60414483a77d6cf /src/libcamera/ipc_pipe_unixsocket.cpp
parentedd70612e520f742600ce997f3b4ab0e0d9236c8 (diff)
libcamera: ipc_unixsocket: Use UniqueFD for a file descriptor
IPCUnixSocket::create() creates two file descriptors. One of them is stored in IPCUnixSocket and the other is returned to a caller. This clarifies the ownership using UniqueFD. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/ipc_pipe_unixsocket.cpp')
-rw-r--r--src/libcamera/ipc_pipe_unixsocket.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcamera/ipc_pipe_unixsocket.cpp b/src/libcamera/ipc_pipe_unixsocket.cpp
index 533560cf..65277500 100644
--- a/src/libcamera/ipc_pipe_unixsocket.cpp
+++ b/src/libcamera/ipc_pipe_unixsocket.cpp
@@ -31,14 +31,14 @@ IPCPipeUnixSocket::IPCPipeUnixSocket(const char *ipaModulePath,
args.push_back(ipaModulePath);
socket_ = std::make_unique<IPCUnixSocket>();
- int fd = socket_->create();
- if (fd < 0) {
+ UniqueFD fd = socket_->create();
+ if (!fd.isValid()) {
LOG(IPCPipe, Error) << "Failed to create socket";
return;
}
socket_->readyRead.connect(this, &IPCPipeUnixSocket::readyRead);
- args.push_back(std::to_string(fd));
- fds.push_back(fd);
+ args.push_back(std::to_string(fd.get()));
+ fds.push_back(fd.release());
proc_ = std::make_unique<Process>();
int ret = proc_->start(ipaProxyWorkerPath, args, fds);