From patchwork Mon Jun 24 19:29:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20373 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id BF026BD87C for ; Mon, 24 Jun 2024 19:30:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33EE2654BB; Mon, 24 Jun 2024 21:30:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PMSY4Jhr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 33BE4654A1 for ; Mon, 24 Jun 2024 21:30:12 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2CA641929; Mon, 24 Jun 2024 21:29:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719257390; bh=CjT1AKIin2El6EqOoEw0L/uzN21PIyPNg3xLusvHwMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PMSY4JhrDXlK0vUCkMDT5pKbaEpaxlNexz+2Rb5sAtTDH38bRmbkznJTM91ui3Hgz TE4B1LY2BFMA04fd7mbcZy8qOUu5WpPq042tpE7Ixnyz9eaX09xoOW1TfxpG/GG3Iu uB2tE4BaypJ9whlc4fb03pmDgZVdOLTWE1/A3thQ= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH 06/10] v4l2: v4l2_compat: Selectively disable -Wmissing-declarations Date: Mon, 24 Jun 2024 22:29:37 +0300 Message-ID: <20240624192941.22943-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240624192941.22943-1-laurent.pinchart@ideasonboard.com> References: <20240624192941.22943-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" _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 Reviewed-by: Kieran Bingham --- 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) {