[{"id":30060,"web_url":"https://patchwork.libcamera.org/comment/30060/","msgid":"<171926513022.625657.9826833157171652852@ping.linuxembedded.co.uk>","date":"2024-06-24T21:38:50","subject":"Re: [PATCH 06/10] v4l2: v4l2_compat: Selectively disable\n\t-Wmissing-declarations","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-06-24 20:29:37)\n> _FORTIFY_SOURCE redirects the open*() calls to __open*_2() functions.\n> The libcamera V4L2 adaptation layer intercepts those functions to\n> support applications compiled with _FORTIFY_SOURCE. When _FORTIFY_SOURCE\n> is not enabled, the C library headers will not provide declarations for\n> the fortified functions, which will cause missing declaration warnings\n> when we unable them.\n> \n> Fix this by disabling the -Wmissing-declarations warnings selectively\n> for the _FORTIFY_SOURCE functions. To avoid sparkling pragmas around,\n> move the relevant function definitions next to each other.\n\nLooks reasonable to keep the fortified versions together. One of either\nyou or Barnabás will need to rebase though...\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/v4l2/v4l2_compat.cpp | 43 ++++++++++++++++++++++++----------------\n>  1 file changed, 26 insertions(+), 17 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> index 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>                                                      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> -       return 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>         return V4L2CompatManager::instance()->openat(AT_FDCWD, path,\n>                                                      oflag | O_LARGEFILE, mode);\n>  }\n> -\n> -LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> -{\n> -       return 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>         return V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode);\n>  }\n>  \n> -LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n> -{\n> -       return 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>         return V4L2CompatManager::instance()->openat(dirfd, path,\n>                                                      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> +       return open(path, oflag);\n> +}\n> +\n> +LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> +{\n> +       return open(path, oflag);\n> +}\n> +\n> +LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n> +{\n> +       return openat(dirfd, path, oflag);\n> +}\n>  \n>  LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)\n>  {\n>         return openat(dirfd, path, oflag);\n>  }\n> -#endif\n> +\n> +#pragma GCC diagnostic pop\n>  \n>  LIBCAMERA_PUBLIC int dup(int oldfd)\n>  {\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 62EEFBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Jun 2024 21:38:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 59CB3654AA;\n\tMon, 24 Jun 2024 23:38:54 +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 4D372654A3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Jun 2024 23:38:53 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1326E1650;\n\tMon, 24 Jun 2024 23:38:31 +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=\"Sefkq6YK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719265111;\n\tbh=mkriUjOuR3aStHAb3Og98dFhahr33RlNaEufai5IK28=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=Sefkq6YKpuCjhxoP+ZqboTHJfqUpnd4GAN0cLGXgTGH+JtPDKCbOL1KEGo7Gnc+p3\n\tVgZw/DbPCTMS/koWokV+Jh8Inhf/Vqvigmsp4jghlI8C4pl5JDlT+Jw1a3WapEuCcv\n\tsMDMtdiavZ1zkVWBA1YaWt2hnMlJAa5ALQm0ZbuA=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240624192941.22943-7-laurent.pinchart@ideasonboard.com>","References":"<20240624192941.22943-1-laurent.pinchart@ideasonboard.com>\n\t<20240624192941.22943-7-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH 06/10] v4l2: v4l2_compat: Selectively disable\n\t-Wmissing-declarations","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 24 Jun 2024 22:38:50 +0100","Message-ID":"<171926513022.625657.9826833157171652852@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":30069,"web_url":"https://patchwork.libcamera.org/comment/30069/","msgid":"<20240625081238.GD29140@pendragon.ideasonboard.com>","date":"2024-06-25T08:12:38","subject":"Re: [PATCH 06/10] v4l2: v4l2_compat: Selectively disable\n\t-Wmissing-declarations","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Jun 24, 2024 at 10:38:50PM +0100, Kieran Bingham wrote:\n> Quoting Laurent Pinchart (2024-06-24 20:29:37)\n> > _FORTIFY_SOURCE redirects the open*() calls to __open*_2() functions.\n> > The libcamera V4L2 adaptation layer intercepts those functions to\n> > support applications compiled with _FORTIFY_SOURCE. When _FORTIFY_SOURCE\n> > is not enabled, the C library headers will not provide declarations for\n> > the fortified functions, which will cause missing declaration warnings\n> > when we unable them.\n> > \n> > Fix this by disabling the -Wmissing-declarations warnings selectively\n> > for the _FORTIFY_SOURCE functions. To avoid sparkling pragmas around,\n> > move the relevant function definitions next to each other.\n> \n> Looks reasonable to keep the fortified versions together. One of either\n> you or Barnabás will need to rebase though...\n\nI've pushed Barnabás patches and rebased this series on top.\n\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/v4l2/v4l2_compat.cpp | 43 ++++++++++++++++++++++++----------------\n> >  1 file changed, 26 insertions(+), 17 deletions(-)\n> > \n> > diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> > index 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> >                                                      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> > -       return 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> >         return V4L2CompatManager::instance()->openat(AT_FDCWD, path,\n> >                                                      oflag | O_LARGEFILE, mode);\n> >  }\n> > -\n> > -LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> > -{\n> > -       return 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> >         return V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode);\n> >  }\n> >  \n> > -LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n> > -{\n> > -       return 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> >         return V4L2CompatManager::instance()->openat(dirfd, path,\n> >                                                      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> > +       return open(path, oflag);\n> > +}\n> > +\n> > +LIBCAMERA_PUBLIC int __open64_2(const char *path, int oflag)\n> > +{\n> > +       return open(path, oflag);\n> > +}\n> > +\n> > +LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag)\n> > +{\n> > +       return openat(dirfd, path, oflag);\n> > +}\n> >  \n> >  LIBCAMERA_PUBLIC int __openat64_2(int dirfd, const char *path, int oflag)\n> >  {\n> >         return openat(dirfd, path, oflag);\n> >  }\n> > -#endif\n> > +\n> > +#pragma GCC diagnostic pop\n> >  \n> >  LIBCAMERA_PUBLIC int dup(int oldfd)\n> >  {","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 C6E65BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Jun 2024 08:13:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 049CF619E8;\n\tTue, 25 Jun 2024 10:13:02 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 35FC7619E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Jun 2024 10:13:00 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [193.209.96.36])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8B24FBEB;\n\tTue, 25 Jun 2024 10:12:37 +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=\"SbvtYBsH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719303157;\n\tbh=6hOel1tI1YMYVG3Cm9C02Qdg8nCN0wNHpKOWPSymXrI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SbvtYBsHLDyCxWxtX1L4xadpK4KE8CMe8B1wcEBTchBI+PSqauAswlUBR5r4anBeW\n\t/SovqL6Kxs34VUWS0Iq/+sFdqqswErjFuqQhD3EJCStj//rZmAbcU5H2xg66QqAdml\n\tROWWgvYsj+a4Q10VPIoOncGmBXyzvKbq9TsrdiXE=","Date":"Tue, 25 Jun 2024 11:12:38 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, =?utf-8?b?QmFybmFiw6FzIFDFkWN6?=\n\t=?utf-8?q?e?= <pobrn@protonmail.com>","Subject":"Re: [PATCH 06/10] v4l2: v4l2_compat: Selectively disable\n\t-Wmissing-declarations","Message-ID":"<20240625081238.GD29140@pendragon.ideasonboard.com>","References":"<20240624192941.22943-1-laurent.pinchart@ideasonboard.com>\n\t<20240624192941.22943-7-laurent.pinchart@ideasonboard.com>\n\t<171926513022.625657.9826833157171652852@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<171926513022.625657.9826833157171652852@ping.linuxembedded.co.uk>","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>"}}]