[PATCH v2 19/20] libcamera: includes: Remove unused includes

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Sep 2 16:44:26 CEST 2024


Hi Milan,

On Mon, Sep 02, 2024 at 04:13:23PM +0200, Milan Zamazal wrote:
> Laurent Pinchart writes:
> > On Fri, Aug 30, 2024 at 05:27:16PM +0200, Milan Zamazal wrote:
> >> The includes that are not used can be removed.
> >> 
> >> Signed-off-by: Milan Zamazal <mzamazal at redhat.com>
> >> ---
> >>  include/libcamera/base/event_dispatcher.h            | 2 --
> >>  include/libcamera/base/log.h                         | 1 -
> >>  include/libcamera/base/memfd.h                       | 2 --
> >>  include/libcamera/base/signal.h                      | 1 -
> >>  include/libcamera/base/span.h                        | 1 -
> >>  include/libcamera/base/timer.h                       | 1 -
> >>  include/libcamera/base/utils.h                       | 1 -
> >>  include/libcamera/framebuffer.h                      | 1 -
> >>  include/libcamera/internal/camera_manager.h          | 1 -
> >>  include/libcamera/internal/camera_sensor.h           | 1 -
> >>  include/libcamera/internal/device_enumerator_sysfs.h | 1 -
> >>  include/libcamera/internal/dma_buf_allocator.h       | 2 --
> >>  include/libcamera/internal/formats.h                 | 1 -
> >>  include/libcamera/internal/ipa_data_serializer.h     | 4 ----
> >>  include/libcamera/internal/ipa_proxy.h               | 2 --
> >>  include/libcamera/internal/ipc_pipe_unixsocket.h     | 1 -
> >>  include/libcamera/internal/media_device.h            | 1 -
> >>  include/libcamera/internal/pipeline_handler.h        | 3 ---
> >>  include/libcamera/internal/shared_mem_object.h       | 1 -
> >>  include/libcamera/pixel_format.h                     | 1 -
> >>  include/libcamera/request.h                          | 1 -
> >>  include/libcamera/stream.h                           | 1 -
> >>  include/libcamera/transform.h                        | 2 --
> >>  23 files changed, 33 deletions(-)
> >> 
> >> diff --git a/include/libcamera/base/event_dispatcher.h b/include/libcamera/base/event_dispatcher.h
> >> index e9a09c6e..408f8da6 100644
> >> --- a/include/libcamera/base/event_dispatcher.h
> >> +++ b/include/libcamera/base/event_dispatcher.h
> >> @@ -7,8 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <vector>
> >> -
> >>  #include <libcamera/base/private.h>
> >>  
> >>  namespace libcamera {
> >> diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
> >> index df27df03..62093012 100644
> >> --- a/include/libcamera/base/log.h
> >> +++ b/include/libcamera/base/log.h
> >> @@ -7,7 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <chrono>
> >>  #include <sstream>
> >>  
> >>  #include <libcamera/base/private.h>
> >> diff --git a/include/libcamera/base/memfd.h b/include/libcamera/base/memfd.h
> >> index b0edd2de..705d9929 100644
> >> --- a/include/libcamera/base/memfd.h
> >> +++ b/include/libcamera/base/memfd.h
> >> @@ -7,8 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <stddef.h>
> >> -
> >
> > Don't we need this for size_t ?
> 
> It would work for size_t but not for std::size_t.  The latter is
> included in several header files, including <cstddef>, but C++ only.
> libcamera permits only <cmath>, which includes std::size_t too, but only
> indirectly; it would be nonsense to import std::size_t this way.
> 
> I'm not sure what's the best to do here.  I'd say nothing -- std::size_t
> is so ubiquitous that it is included some way via almost any C++ header
> file.  If we would like to be 100% clean then I think <cstddef> or
> <cstdlib> should be included but then checkstyle.py had to be modified
> to permit that.
> 
> In any case, including <stddef.h> is truly redundant here.

stddef.h is required to provide ::size_t and may provide std::size_t.
cstddef is required to provide std::size_t and may provide ::size_t. We
currently rely on the fact that both libstdc++ and libc++ provide the
std namespace symbols in the C headers. This isn't the case for
std::size_t only, but for all the other C symbols.

> >>  #include <libcamera/base/flags.h>
> >>  #include <libcamera/base/unique_fd.h>
> >>  
> >> diff --git a/include/libcamera/base/signal.h b/include/libcamera/base/signal.h
> >> index 849fbbda..bbff1495 100644
> >> --- a/include/libcamera/base/signal.h
> >> +++ b/include/libcamera/base/signal.h
> >> @@ -10,7 +10,6 @@
> >>  #include <functional>
> >>  #include <list>
> >>  #include <type_traits>
> >> -#include <vector>
> >>  
> >>  #include <libcamera/base/bound_method.h>
> >>  
> >> diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
> >> index c3e63f69..92cce4f0 100644
> >> --- a/include/libcamera/base/span.h
> >> +++ b/include/libcamera/base/span.h
> >> @@ -10,7 +10,6 @@
> >>  #include <array>
> >>  #include <iterator>
> >>  #include <limits>
> >> -#include <stddef.h>
> >
> > Same.
> >
> >>  #include <type_traits>
> >>  
> >>  namespace libcamera {
> >> diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h
> >> index 5ef45959..9646a0fe 100644
> >> --- a/include/libcamera/base/timer.h
> >> +++ b/include/libcamera/base/timer.h
> >> @@ -8,7 +8,6 @@
> >>  #pragma once
> >>  
> >>  #include <chrono>
> >> -#include <stdint.h>
> >>  
> >>  #include <libcamera/base/private.h>
> >>  
> >> diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
> >> index 734ff81e..98c683a7 100644
> >> --- a/include/libcamera/base/utils.h
> >> +++ b/include/libcamera/base/utils.h
> >> @@ -10,7 +10,6 @@
> >>  #include <algorithm>
> >>  #include <chrono>
> >>  #include <iterator>
> >> -#include <memory>
> >>  #include <ostream>
> >>  #include <sstream>
> >>  #include <string>
> >> diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h
> >> index 5ae2270b..ff839243 100644
> >> --- a/include/libcamera/framebuffer.h
> >> +++ b/include/libcamera/framebuffer.h
> >> @@ -7,7 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <assert.h>
> >>  #include <limits>
> >>  #include <memory>
> >>  #include <stdint.h>
> >> diff --git a/include/libcamera/internal/camera_manager.h b/include/libcamera/internal/camera_manager.h
> >> index e098cb69..0150ca61 100644
> >> --- a/include/libcamera/internal/camera_manager.h
> >> +++ b/include/libcamera/internal/camera_manager.h
> >> @@ -9,7 +9,6 @@
> >>  
> >>  #include <libcamera/camera_manager.h>
> >>  
> >> -#include <map>
> >>  #include <memory>
> >>  #include <sys/types.h>
> >>  #include <vector>
> >> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h
> >> index fc44ab98..a42c15fa 100644
> >> --- a/include/libcamera/internal/camera_sensor.h
> >> +++ b/include/libcamera/internal/camera_sensor.h
> >> @@ -23,7 +23,6 @@
> >>  #include <libcamera/ipa/core_ipa_interface.h>
> >>  
> >>  #include "libcamera/internal/bayer_format.h"
> >> -#include "libcamera/internal/formats.h"
> >>  #include "libcamera/internal/v4l2_subdevice.h"
> >>  
> >>  namespace libcamera {
> >> diff --git a/include/libcamera/internal/device_enumerator_sysfs.h
> >> b/include/libcamera/internal/device_enumerator_sysfs.h
> >> index a5bfc711..4ccc9845 100644
> >> --- a/include/libcamera/internal/device_enumerator_sysfs.h
> >> +++ b/include/libcamera/internal/device_enumerator_sysfs.h
> >> @@ -7,7 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <memory>
> >>  #include <string>
> >>  
> >>  #include "libcamera/internal/device_enumerator.h"
> >> diff --git a/include/libcamera/internal/dma_buf_allocator.h
> >> b/include/libcamera/internal/dma_buf_allocator.h
> >> index 36ec1696..d2a0a0d1 100644
> >> --- a/include/libcamera/internal/dma_buf_allocator.h
> >> +++ b/include/libcamera/internal/dma_buf_allocator.h
> >> @@ -7,8 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <stddef.h>
> >> -
> >
> > Needed for size_t too ?
> >
> >>  #include <libcamera/base/flags.h>
> >>  #include <libcamera/base/unique_fd.h>
> >>  
> >> diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
> >> index 71895cd8..6a3e9c16 100644
> >> --- a/include/libcamera/internal/formats.h
> >> +++ b/include/libcamera/internal/formats.h
> >> @@ -8,7 +8,6 @@
> >>  #pragma once
> >>  
> >>  #include <array>
> >> -#include <map>
> >>  #include <vector>
> >>  
> >>  #include <libcamera/geometry.h>
> >> diff --git a/include/libcamera/internal/ipa_data_serializer.h b/include/libcamera/internal/ipa_data_serializer.h
> >> index 337c948c..13470a89 100644
> >> --- a/include/libcamera/internal/ipa_data_serializer.h
> >> +++ b/include/libcamera/internal/ipa_data_serializer.h
> >> @@ -7,8 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <deque>
> >> -#include <iostream>
> >>  #include <string.h>
> >>  #include <tuple>
> >>  #include <type_traits>
> >> @@ -22,8 +20,6 @@
> >>  #include <libcamera/geometry.h>
> >>  #include <libcamera/ipa/ipa_interface.h>
> >>  
> >> -#include "libcamera/internal/byte_stream_buffer.h"
> >> -#include "libcamera/internal/camera_sensor.h"
> >>  #include "libcamera/internal/control_serializer.h"
> >>  
> >>  namespace libcamera {
> >> diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h
> >> index 0f564d99..983bcc5f 100644
> >> --- a/include/libcamera/internal/ipa_proxy.h
> >> +++ b/include/libcamera/internal/ipa_proxy.h
> >> @@ -7,9 +7,7 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <memory>
> >>  #include <string>
> >> -#include <vector>
> >>  
> >>  #include <libcamera/ipa/ipa_interface.h>
> >>  
> >> diff --git a/include/libcamera/internal/ipc_pipe_unixsocket.h b/include/libcamera/internal/ipc_pipe_unixsocket.h
> >> index 4a0f6d57..8c972613 100644
> >> --- a/include/libcamera/internal/ipc_pipe_unixsocket.h
> >> +++ b/include/libcamera/internal/ipc_pipe_unixsocket.h
> >> @@ -9,7 +9,6 @@
> >>  
> >>  #include <map>
> >>  #include <memory>
> >> -#include <vector>
> >>  
> >>  #include "libcamera/internal/ipc_pipe.h"
> >>  #include "libcamera/internal/ipc_unixsocket.h"
> >> diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h
> >> index bf2e475d..e412d3a0 100644
> >> --- a/include/libcamera/internal/media_device.h
> >> +++ b/include/libcamera/internal/media_device.h
> >> @@ -8,7 +8,6 @@
> >>  #pragma once
> >>  
> >>  #include <map>
> >> -#include <sstream>
> >>  #include <string>
> >>  #include <vector>
> >>  
> >> diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h
> >> index cad5812f..c37e6d02 100644
> >> --- a/include/libcamera/internal/pipeline_handler.h
> >> +++ b/include/libcamera/internal/pipeline_handler.h
> >> @@ -9,7 +9,6 @@
> >>  
> >>  #include <memory>
> >>  #include <queue>
> >> -#include <set>
> >>  #include <string>
> >>  #include <sys/types.h>
> >>  #include <vector>
> >> @@ -20,8 +19,6 @@
> >>  #include <libcamera/controls.h>
> >>  #include <libcamera/stream.h>
> >>  
> >> -#include "libcamera/internal/ipa_proxy.h"
> >> -
> >>  namespace libcamera {
> >>  
> >>  class Camera;
> >> diff --git a/include/libcamera/internal/shared_mem_object.h b/include/libcamera/internal/shared_mem_object.h
> >> index 2ab0189f..e9f1dacd 100644
> >> --- a/include/libcamera/internal/shared_mem_object.h
> >> +++ b/include/libcamera/internal/shared_mem_object.h
> >> @@ -8,7 +8,6 @@
> >>   */
> >>  #pragma once
> >>  
> >> -#include <stddef.h>
> >
> > size_t too.
> >
> >>  #include <stdint.h>
> >>  #include <string>
> >>  #include <sys/mman.h>
> >> diff --git a/include/libcamera/pixel_format.h b/include/libcamera/pixel_format.h
> >> index ea60fe72..1b4d8c7c 100644
> >> --- a/include/libcamera/pixel_format.h
> >> +++ b/include/libcamera/pixel_format.h
> >> @@ -8,7 +8,6 @@
> >>  #pragma once
> >>  
> >>  #include <ostream>
> >> -#include <set>
> >>  #include <stdint.h>
> >>  #include <string>
> >>  
> >> diff --git a/include/libcamera/request.h b/include/libcamera/request.h
> >> index 2c78d9bb..e214a9d1 100644
> >> --- a/include/libcamera/request.h
> >> +++ b/include/libcamera/request.h
> >> @@ -12,7 +12,6 @@
> >>  #include <ostream>
> >>  #include <stdint.h>
> >>  #include <string>
> >> -#include <unordered_set>
> >>  
> >>  #include <libcamera/base/class.h>
> >>  #include <libcamera/base/signal.h>
> >> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> >> index d510238a..071b7169 100644
> >> --- a/include/libcamera/stream.h
> >> +++ b/include/libcamera/stream.h
> >> @@ -8,7 +8,6 @@
> >>  #pragma once
> >>  
> >>  #include <map>
> >> -#include <memory>
> >>  #include <ostream>
> >>  #include <string>
> >>  #include <vector>
> >> diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h
> >> index a88f809e..4517412a 100644
> >> --- a/include/libcamera/transform.h
> >> +++ b/include/libcamera/transform.h
> >> @@ -7,8 +7,6 @@
> >>  
> >>  #pragma once
> >>  
> >> -#include <string>
> >> -
> >>  namespace libcamera {
> >>  
> >>  enum class Orientation;
> 

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list