[{"id":3319,"web_url":"https://patchwork.libcamera.org/comment/3319/","msgid":"<20200104060327.GA5021@localhost.localdomain>","date":"2020-01-04T06:03:27","subject":"Re: [libcamera-devel] [PATCH] v4l2: Fix compilation of __open_2()\n\tand __openat_2() with gcc","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Sat, Jan 04, 2020 at 07:24:23AM +0200, Laurent Pinchart wrote:\n> The __open_2() and __openat_2() functions are defined by glibc as taking\n> 2 and 3 arguments respectively, with variadic arguments for the file\n> mode as open() and openat() do. The V4L2 compatibility layer defines\n> them as aliases for open() and openat(), which results in compilation\n> failures with gcc:\n> \n> ../../src/v4l2/v4l2_compat.cpp: In function ‘int __openat_2(int, const char*, int)’:\n> ../../src/v4l2/v4l2_compat.cpp:58:14: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]\n>    58 |  return open(dirfd, path, oflag);\n>       |              ^~~~~\n>       |              |\n>       |              int\n> ../../src/v4l2/v4l2_compat.cpp:31:39: note:   initializing argument 1 of ‘int open(const char*, int, ...)’\n>    31 | LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...)\n>       |                           ~~~~~~~~~~~~^~~~\n> ../../src/v4l2/v4l2_compat.cpp:58:21: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive]\n>    58 |  return open(dirfd, path, oflag);\n>       |                     ^~~~\n>       |                     |\n>       |                     const char*\n> ../../src/v4l2/v4l2_compat.cpp:31:49: note:   initializing argument 2 of ‘int open(const char*, int, ...)’\n>    31 | LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...)\n>       |\n> \n> Fix this by defining the two functions as wrappers around open() and\n> openat() without variadic arguments.\n> \n> Fixes: 0ce8f2390b52 (\"v4l2: v4l2_compat: Add V4L2 compatibility layer\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/v4l2/v4l2_compat.cpp | 10 ++++++++--\n>  1 file changed, 8 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp\n> index 171ebed6f95b..a162037f6dc7 100644\n> --- a/src/v4l2/v4l2_compat.cpp\n> +++ b/src/v4l2/v4l2_compat.cpp\n> @@ -39,7 +39,10 @@ LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...)\n>  }\n>  \n>  /* _FORTIFY_SOURCE redirects open to __open_2 */\n> -LIBCAMERA_PUBLIC extern __typeof(open) __open_2 __attribute__ ((alias(\"open\")));\n> +LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag)\n> +{\n> +\treturn open(path, oflag);\n> +}\n>  \n>  LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...)\n>  {\n> @@ -50,7 +53,10 @@ 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 extern __typeof(openat) __openat_2 __attribute__ ((alias(\"openat\")));\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 dup(int oldfd)\n>  {\n\nI can't really test it as I can't reproduce the compilation problem, but\nlooks good to me, especially if it fixes the problem for you.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>","headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AE6060461\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jan 2020 07:03:32 +0100 (CET)","from localhost.localdomain (unknown [96.44.9.94])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A3572A49;\n\tSat,  4 Jan 2020 07:03:31 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1578117812;\n\tbh=0teFXO715OxRFf2vTFCw+gxZ44kbgApBml+1u0XuKMM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=S+FMOdEUPO6WkyGDRoa/rQbXui4wGL8abavp/qnzZG4jcnZg3jU3AGm9Q5wBfj+x1\n\tlTmH+BHKIXhliHw9FtS8SWSFaH1mAuA/5aqTQanucLdLxMrCD31LXXJajCR3wtHDSN\n\tJcYl6wcTl6lfZjK82NWnRs1WtP61R1J871yh6UAk=","Date":"Sat, 4 Jan 2020 01:03:27 -0500","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200104060327.GA5021@localhost.localdomain>","References":"<20200104052423.11245-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200104052423.11245-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] v4l2: Fix compilation of __open_2()\n\tand __openat_2() with gcc","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>","X-List-Received-Date":"Sat, 04 Jan 2020 06:03:32 -0000"}}]