[libcamera-devel,1/2] android: Don't rely on indirect inclusion of unistd.h
diff mbox series

Message ID 20210527010149.30601-1-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] android: Don't rely on indirect inclusion of unistd.h
Related show

Commit Message

Laurent Pinchart May 27, 2021, 1:01 a.m. UTC
The standard C library close() and lseek() functions require inclusion
of the unistd.h header. Include it explicitly where needed instead of
relying on indirect inclusion.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/android/camera_device.cpp            | 1 +
 src/android/camera_worker.cpp            | 1 +
 src/android/mm/generic_camera_buffer.cpp | 2 ++
 3 files changed, 4 insertions(+)

Comments

Hirokazu Honda May 27, 2021, 2:49 a.m. UTC | #1
Hi Laurent, thank you for the patch.

On Thu, May 27, 2021 at 10:02 AM Laurent Pinchart <
laurent.pinchart@ideasonboard.com> wrote:

> The standard C library close() and lseek() functions require inclusion
> of the unistd.h header. Include it explicitly where needed instead of
> relying on indirect inclusion.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>

Do you know where unistd.h are indirectly included from?

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

> ---
>  src/android/camera_device.cpp            | 1 +
>  src/android/camera_worker.cpp            | 1 +
>  src/android/mm/generic_camera_buffer.cpp | 2 ++
>  3 files changed, 4 insertions(+)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 7fc4ddb024c1..81509f57d1b7 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -15,6 +15,7 @@
>  #include <fstream>
>  #include <sys/mman.h>
>  #include <tuple>
> +#include <unistd.h>
>  #include <vector>
>
>  #include <libcamera/control_ids.h>
> diff --git a/src/android/camera_worker.cpp b/src/android/camera_worker.cpp
> index 9f727826e23f..98dddd9eb13b 100644
> --- a/src/android/camera_worker.cpp
> +++ b/src/android/camera_worker.cpp
> @@ -10,6 +10,7 @@
>  #include <errno.h>
>  #include <string.h>
>  #include <sys/poll.h>
> +#include <unistd.h>
>
>  #include "camera_device.h"
>
> diff --git a/src/android/mm/generic_camera_buffer.cpp
> b/src/android/mm/generic_camera_buffer.cpp
> index 334498c1867f..cca88cf3632f 100644
> --- a/src/android/mm/generic_camera_buffer.cpp
> +++ b/src/android/mm/generic_camera_buffer.cpp
> @@ -7,6 +7,8 @@
>
>  #include "../camera_buffer.h"
>
> +#include <unistd.h>
> +
>  #include "libcamera/internal/buffer.h"
>  #include "libcamera/internal/log.h"
>
> --
> Regards,
>
> Laurent Pinchart
>
>
Laurent Pinchart May 27, 2021, 2:52 a.m. UTC | #2
Hi Hiro,

On Thu, May 27, 2021 at 11:49:10AM +0900, Hirokazu Honda wrote:
> On Thu, May 27, 2021 at 10:02 AM Laurent Pinchart wrote:
> 
> > The standard C library close() and lseek() functions require inclusion
> > of the unistd.h header. Include it explicitly where needed instead of
> > relying on indirect inclusion.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Do you know where unistd.h are indirectly included from?

Android headers, as I noticed a compilation breakage when updating them
:-)

> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> 
> > ---
> >  src/android/camera_device.cpp            | 1 +
> >  src/android/camera_worker.cpp            | 1 +
> >  src/android/mm/generic_camera_buffer.cpp | 2 ++
> >  3 files changed, 4 insertions(+)
> >
> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> > index 7fc4ddb024c1..81509f57d1b7 100644
> > --- a/src/android/camera_device.cpp
> > +++ b/src/android/camera_device.cpp
> > @@ -15,6 +15,7 @@
> >  #include <fstream>
> >  #include <sys/mman.h>
> >  #include <tuple>
> > +#include <unistd.h>
> >  #include <vector>
> >
> >  #include <libcamera/control_ids.h>
> > diff --git a/src/android/camera_worker.cpp b/src/android/camera_worker.cpp
> > index 9f727826e23f..98dddd9eb13b 100644
> > --- a/src/android/camera_worker.cpp
> > +++ b/src/android/camera_worker.cpp
> > @@ -10,6 +10,7 @@
> >  #include <errno.h>
> >  #include <string.h>
> >  #include <sys/poll.h>
> > +#include <unistd.h>
> >
> >  #include "camera_device.h"
> >
> > diff --git a/src/android/mm/generic_camera_buffer.cpp
> > b/src/android/mm/generic_camera_buffer.cpp
> > index 334498c1867f..cca88cf3632f 100644
> > --- a/src/android/mm/generic_camera_buffer.cpp
> > +++ b/src/android/mm/generic_camera_buffer.cpp
> > @@ -7,6 +7,8 @@
> >
> >  #include "../camera_buffer.h"
> >
> > +#include <unistd.h>
> > +
> >  #include "libcamera/internal/buffer.h"
> >  #include "libcamera/internal/log.h"
> >
Hirokazu Honda May 27, 2021, 3:08 a.m. UTC | #3
Hi Laurent,

On Thu, May 27, 2021 at 11:52 AM Laurent Pinchart <
laurent.pinchart@ideasonboard.com> wrote:

> Hi Hiro,
>
> On Thu, May 27, 2021 at 11:49:10AM +0900, Hirokazu Honda wrote:
> > On Thu, May 27, 2021 at 10:02 AM Laurent Pinchart wrote:
> >
> > > The standard C library close() and lseek() functions require inclusion
> > > of the unistd.h header. Include it explicitly where needed instead of
> > > relying on indirect inclusion.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> > Do you know where unistd.h are indirectly included from?
>
> Android headers, as I noticed a compilation breakage when updating them
> :-)
>
>
Acked. Thanks for fixing.


> > Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
> >
> > > ---
> > >  src/android/camera_device.cpp            | 1 +
> > >  src/android/camera_worker.cpp            | 1 +
> > >  src/android/mm/generic_camera_buffer.cpp | 2 ++
> > >  3 files changed, 4 insertions(+)
> > >
> > > diff --git a/src/android/camera_device.cpp
> b/src/android/camera_device.cpp
> > > index 7fc4ddb024c1..81509f57d1b7 100644
> > > --- a/src/android/camera_device.cpp
> > > +++ b/src/android/camera_device.cpp
> > > @@ -15,6 +15,7 @@
> > >  #include <fstream>
> > >  #include <sys/mman.h>
> > >  #include <tuple>
> > > +#include <unistd.h>
> > >  #include <vector>
> > >
> > >  #include <libcamera/control_ids.h>
> > > diff --git a/src/android/camera_worker.cpp
> b/src/android/camera_worker.cpp
> > > index 9f727826e23f..98dddd9eb13b 100644
> > > --- a/src/android/camera_worker.cpp
> > > +++ b/src/android/camera_worker.cpp
> > > @@ -10,6 +10,7 @@
> > >  #include <errno.h>
> > >  #include <string.h>
> > >  #include <sys/poll.h>
> > > +#include <unistd.h>
> > >
> > >  #include "camera_device.h"
> > >
> > > diff --git a/src/android/mm/generic_camera_buffer.cpp
> > > b/src/android/mm/generic_camera_buffer.cpp
> > > index 334498c1867f..cca88cf3632f 100644
> > > --- a/src/android/mm/generic_camera_buffer.cpp
> > > +++ b/src/android/mm/generic_camera_buffer.cpp
> > > @@ -7,6 +7,8 @@
> > >
> > >  #include "../camera_buffer.h"
> > >
> > > +#include <unistd.h>
> > > +
> > >  #include "libcamera/internal/buffer.h"
> > >  #include "libcamera/internal/log.h"
> > >
>
> --
> Regards,
>
> Laurent Pinchart
>
Paul Elder May 31, 2021, 8:50 a.m. UTC | #4
Hi Laurent,

On Thu, May 27, 2021 at 04:01:48AM +0300, Laurent Pinchart wrote:
> The standard C library close() and lseek() functions require inclusion
> of the unistd.h header. Include it explicitly where needed instead of
> relying on indirect inclusion.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Doesn't regress CTS :)

Tested-by: Paul Elder <paul.elder@ideasonboard.com>

> ---
>  src/android/camera_device.cpp            | 1 +
>  src/android/camera_worker.cpp            | 1 +
>  src/android/mm/generic_camera_buffer.cpp | 2 ++
>  3 files changed, 4 insertions(+)
> 
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 7fc4ddb024c1..81509f57d1b7 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -15,6 +15,7 @@
>  #include <fstream>
>  #include <sys/mman.h>
>  #include <tuple>
> +#include <unistd.h>
>  #include <vector>
>  
>  #include <libcamera/control_ids.h>
> diff --git a/src/android/camera_worker.cpp b/src/android/camera_worker.cpp
> index 9f727826e23f..98dddd9eb13b 100644
> --- a/src/android/camera_worker.cpp
> +++ b/src/android/camera_worker.cpp
> @@ -10,6 +10,7 @@
>  #include <errno.h>
>  #include <string.h>
>  #include <sys/poll.h>
> +#include <unistd.h>
>  
>  #include "camera_device.h"
>  
> diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp
> index 334498c1867f..cca88cf3632f 100644
> --- a/src/android/mm/generic_camera_buffer.cpp
> +++ b/src/android/mm/generic_camera_buffer.cpp
> @@ -7,6 +7,8 @@
>  
>  #include "../camera_buffer.h"
>  
> +#include <unistd.h>
> +
>  #include "libcamera/internal/buffer.h"
>  #include "libcamera/internal/log.h"
>  
> -- 
> Regards,
> 
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 7fc4ddb024c1..81509f57d1b7 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -15,6 +15,7 @@ 
 #include <fstream>
 #include <sys/mman.h>
 #include <tuple>
+#include <unistd.h>
 #include <vector>
 
 #include <libcamera/control_ids.h>
diff --git a/src/android/camera_worker.cpp b/src/android/camera_worker.cpp
index 9f727826e23f..98dddd9eb13b 100644
--- a/src/android/camera_worker.cpp
+++ b/src/android/camera_worker.cpp
@@ -10,6 +10,7 @@ 
 #include <errno.h>
 #include <string.h>
 #include <sys/poll.h>
+#include <unistd.h>
 
 #include "camera_device.h"
 
diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp
index 334498c1867f..cca88cf3632f 100644
--- a/src/android/mm/generic_camera_buffer.cpp
+++ b/src/android/mm/generic_camera_buffer.cpp
@@ -7,6 +7,8 @@ 
 
 #include "../camera_buffer.h"
 
+#include <unistd.h>
+
 #include "libcamera/internal/buffer.h"
 #include "libcamera/internal/log.h"