v4l2: v4l2_compat: Selectively disable -Wmissing-declarations
_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. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
1907c883ca
commit
cdb05b3712
1 changed files with 29 additions and 20 deletions
|
@ -56,13 +56,6 @@ LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...)
|
||||||
oflag, mode);
|
oflag, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* _FORTIFY_SOURCE redirects open to __open_2 */
|
|
||||||
LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)
|
|
||||||
{
|
|
||||||
assert(!needs_mode(oflag));
|
|
||||||
return open(path, oflag);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef open64
|
#ifndef open64
|
||||||
LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)
|
LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)
|
||||||
{
|
{
|
||||||
|
@ -73,12 +66,6 @@ LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)
|
||||||
return V4L2CompatManager::instance()->openat(AT_FDCWD, path,
|
return V4L2CompatManager::instance()->openat(AT_FDCWD, path,
|
||||||
oflag | O_LARGEFILE, mode);
|
oflag | O_LARGEFILE, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)
|
|
||||||
{
|
|
||||||
assert(!needs_mode(oflag));
|
|
||||||
return open64(path, oflag);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)
|
LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)
|
||||||
|
@ -90,12 +77,6 @@ LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)
|
||||||
return V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode);
|
return V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)
|
|
||||||
{
|
|
||||||
assert(!needs_mode(oflag));
|
|
||||||
return openat(dirfd, path, oflag);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef openat64
|
#ifndef openat64
|
||||||
LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)
|
LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)
|
||||||
{
|
{
|
||||||
|
@ -106,13 +87,41 @@ LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)
|
||||||
return V4L2CompatManager::instance()->openat(dirfd, path,
|
return V4L2CompatManager::instance()->openat(dirfd, path,
|
||||||
oflag | O_LARGEFILE, mode);
|
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)
|
||||||
|
{
|
||||||
|
assert(!needs_mode(oflag));
|
||||||
|
return open(path, oflag);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)
|
||||||
|
{
|
||||||
|
assert(!needs_mode(oflag));
|
||||||
|
return open64(path, oflag);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)
|
||||||
|
{
|
||||||
|
assert(!needs_mode(oflag));
|
||||||
|
return openat(dirfd, path, oflag);
|
||||||
|
}
|
||||||
|
|
||||||
LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)
|
LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)
|
||||||
{
|
{
|
||||||
assert(!needs_mode(oflag));
|
assert(!needs_mode(oflag));
|
||||||
return openat64(dirfd, path, oflag);
|
return openat64(dirfd, path, oflag);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
LIBCAMERA_PUBLIC int dup(int oldfd)
|
LIBCAMERA_PUBLIC int dup(int oldfd)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue