[libcamera-devel] [PATCH 3/3] libcamera: v4l2_videodevice: Use FileDescriptor "fd move" constructor
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Mon May 18 18:48:04 CEST 2020
Use the newly added "fd move" constructor of the FileDescriptor class to
avoid dup() + close().
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/libcamera/v4l2_videodevice.cpp | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index fbe55bc6f54f..3614b2ed1cbc 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1276,14 +1276,7 @@ FileDescriptor V4L2VideoDevice::exportDmabufFd(unsigned int index,
return FileDescriptor();
}
- FileDescriptor fd(expbuf.fd);
- /*
- * FileDescriptor takes a duplicate of fd, so we must close the
- * original here, otherwise it will be left dangling.
- */
- ::close(expbuf.fd);
-
- return fd;
+ return FileDescriptor(std::move(expbuf.fd));
}
/**
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list