From patchwork Sat Jan 4 05:24:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2511 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EFB7B60461 for ; Sat, 4 Jan 2020 06:24:37 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7E78030F for ; Sat, 4 Jan 2020 06:24:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1578115477; bh=Ren1tmoDSw4Y3qKw2DZe+7fepqR9TbEYOyaS4EZLRkk=; h=From:To:Subject:Date:From; b=nSYTf93gbloEJQvzLNgLITgkynyIPW2Ga9N3jur+QnioWpxOJ3ch98D43/oEwm7Xl nRvGUyqfL/t3XrOZD0o5FLywi8w989y4es5CFT+gYRQ/82AiPVeQ+ENo3KJ+UDz9uw yOPJA8+SEIaFB9ZSGzhMX8TPdo7vfe7oM4iJPTME= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jan 2020 07:24:23 +0200 Message-Id: <20200104052423.11245-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] v4l2: Fix compilation of __open_2() and __openat_2() with gcc 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: , X-List-Received-Date: Sat, 04 Jan 2020 05:24:38 -0000 The __open_2() and __openat_2() functions are defined by glibc as taking 2 and 3 arguments respectively, with variadic arguments for the file mode as open() and openat() do. The V4L2 compatibility layer defines them as aliases for open() and openat(), which results in compilation failures with gcc: ../../src/v4l2/v4l2_compat.cpp: In function ‘int __openat_2(int, const char*, int)’: ../../src/v4l2/v4l2_compat.cpp:58:14: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive] 58 | return open(dirfd, path, oflag); | ^~~~~ | | | int ../../src/v4l2/v4l2_compat.cpp:31:39: note: initializing argument 1 of ‘int open(const char*, int, ...)’ 31 | LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...) | ~~~~~~~~~~~~^~~~ ../../src/v4l2/v4l2_compat.cpp:58:21: error: invalid conversion from ‘const char*’ to ‘int’ [-fpermissive] 58 | return open(dirfd, path, oflag); | ^~~~ | | | const char* ../../src/v4l2/v4l2_compat.cpp:31:49: note: initializing argument 2 of ‘int open(const char*, int, ...)’ 31 | LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...) | Fix this by defining the two functions as wrappers around open() and openat() without variadic arguments. Fixes: 0ce8f2390b52 ("v4l2: v4l2_compat: Add V4L2 compatibility layer") Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/v4l2/v4l2_compat.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/v4l2/v4l2_compat.cpp b/src/v4l2/v4l2_compat.cpp index 171ebed6f95b..a162037f6dc7 100644 --- a/src/v4l2/v4l2_compat.cpp +++ b/src/v4l2/v4l2_compat.cpp @@ -39,7 +39,10 @@ LIBCAMERA_PUBLIC int open(const char *path, int oflag, ...) } /* _FORTIFY_SOURCE redirects open to __open_2 */ -LIBCAMERA_PUBLIC extern __typeof(open) __open_2 __attribute__ ((alias("open"))); +LIBCAMERA_PUBLIC int __open_2(const char *path, int oflag) +{ + return open(path, oflag); +} LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...) { @@ -50,7 +53,10 @@ LIBCAMERA_PUBLIC int openat(int dirfd, const char *path, int oflag, ...) return V4L2CompatManager::instance()->openat(dirfd, path, oflag, mode); } -LIBCAMERA_PUBLIC extern __typeof(openat) __openat_2 __attribute__ ((alias("openat"))); +LIBCAMERA_PUBLIC int __openat_2(int dirfd, const char *path, int oflag) +{ + return openat(dirfd, path, oflag); +} LIBCAMERA_PUBLIC int dup(int oldfd) {