[PATCH 06/10] v4l2: v4l2_compat: Selectively disable -Wmissing-declarations

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Jun 25 10:12:38 CEST 2024


On Mon, Jun 24, 2024 at 10:38:50PM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart (2024-06-24 20:29:37)
> > _FORTIFY_SOURCE redirects the open*() calls to __open*_2() functions.
> > The libcamera V4L2 adaptation layer intercepts those functions to
> > support applications compiled with _FORTIFY_SOURCE. When _FORTIFY_SOURCE
> > is not enabled, the C library headers will not provide declarations for
> > the fortified functions, which will cause missing declaration warnings
> > when we unable them.
> > 
> > Fix this by disabling the -Wmissing-declarations warnings selectively
> > for the _FORTIFY_SOURCE functions. To avoid sparkling pragmas around,
> > move the relevant function definitions next to each other.
> 
> Looks reasonable to keep the fortified versions together. One of either
> you or Barnabás will need to rebase though...

I've pushed Barnabás patches and rebased this series on top.

> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > ---
> >  src/v4l2/v4l2_compat.cpp | 43 ++++++++++++++++++++++++----------------
> >  1 file changed, 26 insertions(+), 17 deletions(-)
> > 
> > diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp
> > index 9dd1577dfbde..8ff93192c3e3 100644
> > --- a/src/v4l2/v4l2_compat.cpp
> > +++ b/src/v4l2/v4l2_compat.cpp
> > @@ -42,12 +42,6 @@ LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...)
> >                                                      oflag, mode);
> >  }
> >  
> > -/* _FORTIFY_SOURCE redirects open to __open_2 */
> > -LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)
> > -{
> > -       return open(path, oflag);
> > -}
> > -
> >  #ifndef open64
> >  LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)
> >  {
> > @@ -58,11 +52,6 @@ LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)
> >         return V4L2CompatManager::instance()->openat(AT_FDCWD, path,
> >                                                      oflag | O_LARGEFILE, mode);
> >  }
> > -
> > -LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)
> > -{
> > -       return open(path, oflag);
> > -}
> >  #endif
> >  
> >  LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)
> > @@ -74,11 +63,6 @@ LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)
> >         return V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode);
> >  }
> >  
> > -LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)
> > -{
> > -       return openat(dirfd, path, oflag);
> > -}
> > -
> >  #ifndef openat64
> >  LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)
> >  {
> > @@ -89,12 +73,37 @@ LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)
> >         return V4L2CompatManager::instance()->openat(dirfd, path,
> >                                                      oflag | O_LARGEFILE, mode);
> >  }
> > +#endif
> > +
> > +/*
> > + * _FORTIFY_SOURCE redirects open* to __open*_2. Disable the
> > + * -Wmissing-declarations warnings, as the functions won't be declared if
> > + *  _FORTIFY_SOURCE is not in use.
> > + */
> > +#pragma GCC diagnostic push
> > +#pragma GCC diagnostic ignored "-Wmissing-declarations"
> > +
> > +LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)
> > +{
> > +       return open(path, oflag);
> > +}
> > +
> > +LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)
> > +{
> > +       return open(path, oflag);
> > +}
> > +
> > +LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)
> > +{
> > +       return openat(dirfd, path, oflag);
> > +}
> >  
> >  LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)
> >  {
> >         return openat(dirfd, path, oflag);
> >  }
> > -#endif
> > +
> > +#pragma GCC diagnostic pop
> >  
> >  LIBCAMERA_PUBLIC int dup(int oldfd)
> >  {

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list