{"id":20373,"url":"https://patchwork.libcamera.org/api/patches/20373/?format=json","web_url":"https://patchwork.libcamera.org/patch/20373/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20240624192941.22943-7-laurent.pinchart@ideasonboard.com>","date":"2024-06-24T19:29:37","name":"[06/10] v4l2: v4l2_compat: Selectively disable -Wmissing-declarations","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"0612ab03945b5c7b85be8cdd24002c64d95aa2a0","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20373/mbox/","series":[{"id":4413,"url":"https://patchwork.libcamera.org/api/series/4413/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4413","date":"2024-06-24T19:29:31","name":"libcamera: Enable -Wmissing-declarations","version":1,"mbox":"https://patchwork.libcamera.org/series/4413/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20373/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20373/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BF026BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Jun 2024 19:30:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 33EE2654BB;\n\tMon, 24 Jun 2024 21:30:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 33BE4654A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Jun 2024 21:30:12 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2CA641929;\n\tMon, 24 Jun 2024 21:29:50 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"PMSY4Jhr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719257390;\n\tbh=CjT1AKIin2El6EqOoEw0L/uzN21PIyPNg3xLusvHwMw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=PMSY4JhrDXlK0vUCkMDT5pKbaEpaxlNexz+2Rb5sAtTDH38bRmbkznJTM91ui3Hgz\n\tTE4B1LY2BFMA04fd7mbcZy8qOUu5WpPq042tpE7Ixnyz9eaX09xoOW1TfxpG/GG3Iu\n\tuB2tE4BaypJ9whlc4fb03pmDgZVdOLTWE1/A3thQ=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","Subject":"[PATCH 06/10] v4l2: v4l2_compat: Selectively disable\n\t-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","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"_FORTIFY_SOURCE redirects the open*() calls to __open*_2() functions.\nThe libcamera V4L2 adaptation layer intercepts those functions to\nsupport applications compiled with _FORTIFY_SOURCE. When _FORTIFY_SOURCE\nis not enabled, the C library headers will not provide declarations for\nthe fortified functions, which will cause missing declaration warnings\nwhen we unable them.\n\nFix this by disabling the -Wmissing-declarations warnings selectively\nfor the _FORTIFY_SOURCE functions. To avoid sparkling pragmas around,\nmove the relevant function definitions next to each other.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/v4l2/v4l2_compat.cpp | 43 ++++++++++++++++++++++++----------------\n 1 file changed, 26 insertions(+), 17 deletions(-)","diff":"diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\nindex 9dd1577dfbde..8ff93192c3e3 100644\n--- a/src/v4l2/v4l2_compat.cpp\n+++ b/src/v4l2/v4l2_compat.cpp\n@@ -42,12 +42,6 @@ LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...)\n \t\t\t\t\t\t     oflag, mode);\n }\n \n-/* _FORTIFY_SOURCE redirects open to __open_2 */\n-LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)\n-{\n-\treturn open(path, oflag);\n-}\n-\n #ifndef open64\n LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)\n {\n@@ -58,11 +52,6 @@ LIBCAMERA_PUBLIC int open64(const char *path, int oflag, ...)\n \treturn V4L2CompatManager::instance()->openat(AT_FDCWD, path,\n \t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n }\n-\n-LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n-{\n-\treturn open(path, oflag);\n-}\n #endif\n \n LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)\n@@ -74,11 +63,6 @@ LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)\n \treturn V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode);\n }\n \n-LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n-{\n-\treturn openat(dirfd, path, oflag);\n-}\n-\n #ifndef openat64\n LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)\n {\n@@ -89,12 +73,37 @@ LIBCAMERA_PUBLIC int openat64(int dirfd, const char *path, int oflag, ...)\n \treturn V4L2CompatManager::instance()->openat(dirfd, path,\n \t\t\t\t\t\t     oflag | O_LARGEFILE, mode);\n }\n+#endif\n+\n+/*\n+ * _FORTIFY_SOURCE redirects open* to __open*_2. Disable the\n+ * -Wmissing-declarations warnings, as the functions won't be declared if\n+ *  _FORTIFY_SOURCE is not in use.\n+ */\n+#pragma GCC diagnostic push\n+#pragma GCC diagnostic ignored \"-Wmissing-declarations\"\n+\n+LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)\n+{\n+\treturn open(path, oflag);\n+}\n+\n+LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n+{\n+\treturn open(path, oflag);\n+}\n+\n+LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n+{\n+\treturn openat(dirfd, path, oflag);\n+}\n \n LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)\n {\n \treturn openat(dirfd, path, oflag);\n }\n-#endif\n+\n+#pragma GCC diagnostic pop\n \n LIBCAMERA_PUBLIC int dup(int oldfd)\n {\n","prefixes":["06/10"]}