libcamera: v4l2_videodevice: Use FileDescriptor "fd move" constructor

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>
This commit is contained in:
Laurent Pinchart 2020-05-18 16:35:10 +03:00
parent c7463138c6
commit dfa25e1833

View file

@ -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));
}
/**