[libcamera-devel,v2,00/10] Introduce ScopedFD
mbox series

Message ID 20210610075027.523672-1-hiroh@chromium.org
Headers show
Series
  • Introduce ScopedFD
Related show

Message

Hirokazu Honda June 10, 2021, 7:50 a.m. UTC
This series introduces ScopedFD that is a file descriptor wrapper
that owns a file descriptor and acts like unique_ptr.
It enables to not only reduce close() manually, but also clarify an
ownership of a file descriptor.

Change in v2
- Address Lauren'ts comments to v1

Hirokazu Honda (10):
  libcamera: ScopedFD: Introduce ScopedFD
  libcamera: EventDispatcherPoll: Manage fd by ScopedFD
  libcamera: File: Manage fd by ScopedFD
  libcamera: Process: Manage pipe fds by ScopedFD
  libcamera: MediaDevice: Manage fd by ScopedFD
  libcamera: V4L2Device: Use ScopedFD for a file descriptor
  libcamera: V4L2VideoDevice: Use fd for a file descriptor
  libcamera: IPCUnixSocket: Use ScopedFD for a file descriptor
  libcamera: pipeline: raspberrypi: DmaHeaps: Use ScopedFD for a file
    descriptor
  v4l2: V4L2Camera: Return int in getBufferFd()

 include/libcamera/file_descriptor.h           |   3 +
 .../internal/event_dispatcher_poll.h          |   4 +-
 include/libcamera/internal/file.h             |   5 +-
 include/libcamera/internal/ipc_unixsocket.h   |   5 +-
 include/libcamera/internal/media_device.h     |   3 +-
 include/libcamera/internal/process.h          |   4 +-
 include/libcamera/internal/v4l2_device.h      |   9 +-
 include/libcamera/internal/v4l2_videodevice.h |   4 +-
 include/libcamera/meson.build                 |   1 +
 include/libcamera/scoped_fd.h                 |  36 +++++
 src/libcamera/event_dispatcher_poll.cpp       |  11 +-
 src/libcamera/file.cpp                        |  25 ++--
 src/libcamera/file_descriptor.cpp             |  20 +++
 src/libcamera/ipc_pipe_unixsocket.cpp         |   8 +-
 src/libcamera/ipc_unixsocket.cpp              |  40 +++---
 src/libcamera/media_device.cpp                |  39 +++---
 src/libcamera/meson.build                     |   1 +
 .../pipeline/raspberrypi/dma_heaps.cpp        |  23 ++--
 .../pipeline/raspberrypi/dma_heaps.h          |  10 +-
 .../pipeline/raspberrypi/raspberrypi.cpp      |   7 +-
 src/libcamera/process.cpp                     |  16 ++-
 src/libcamera/scoped_fd.cpp                   | 129 ++++++++++++++++++
 src/libcamera/v4l2_device.cpp                 |  26 ++--
 src/libcamera/v4l2_videodevice.cpp            |  48 +++----
 src/v4l2/v4l2_camera.cpp                      |   6 +-
 src/v4l2/v4l2_camera.h                        |   2 +-
 src/v4l2/v4l2_camera_proxy.cpp                |   6 +-
 test/ipc/unixsocket.cpp                       |   6 +-
 28 files changed, 339 insertions(+), 158 deletions(-)
 create mode 100644 include/libcamera/scoped_fd.h
 create mode 100644 src/libcamera/scoped_fd.cpp

--
2.32.0.rc1.229.g3e70b5a671-goog