libcamera/include
Laurent Pinchart 206fada99d libcamera: file_descriptor: Implement move semantics for constructor
The FileDescriptor class, when constructed from a numerical file
descriptor, duplicates the file descriptor and takes ownership of the
copy. The caller has to close the original file descriptor manually if
needed. This is inefficient as the dup() and close() calls could be
avoided, but can also lead to resource leakage, as recently shown by
commit 353fc4c223 ("libcamera: v4l2_videodevice: Fix dangling file
descriptor").

In an attempt to solve this problem, implement move semantics for the
FileDescriptor constructor. The constructor taking a numerical file
descriptor is split in two variants:

- A "fd copy" constructor that takes a const lvalue reference to a
  numerical file descriptor and duplicates it (corresponding to the
  current behaviour).
- A "fd move" constructor that takes a rvalue reference to a numerical
  file descriptor and takes ownership of it.

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>
2020-05-19 18:07:49 +03:00
..
android licenses: License all meson files under CC0-1.0 2020-05-13 16:46:24 +03:00
libcamera libcamera: file_descriptor: Implement move semantics for constructor 2020-05-19 18:07:49 +03:00
linux include: uapi: Add header definitions for BCM2835 Unicam and ISP blocks 2020-05-11 23:53:58 +03:00
meson.build libcamera: Move IPA headers from include/ipa/ to include/libcamera/ipa/ 2020-05-16 03:38:47 +03:00