From dfa25e18334c9dc68b1939c62d6b711ece153f92 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date: Mon, 18 May 2020 16:35:10 +0300
Subject: libcamera: v4l2_videodevice: Use FileDescriptor "fd move" constructor
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Use the newly added "fd move" constructor of the FileDescriptor class to
avoid dup() + close().

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
---
 src/libcamera/v4l2_videodevice.cpp | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

(limited to 'src')

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index fbe55bc6..3614b2ed 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));
 }
 
 /**
-- 
cgit v1.2.1