diff mbox series

[v4l-utils] libv4l2: Guard the v4l2_ioctl function with HAVE_POSIX_IOCTL

Message ID 20240906124629.11660-3-vadorovsky@gmail.com (mailing list archive)
State New
Headers show
Series [v4l-utils] libv4l2: Guard the v4l2_ioctl function with HAVE_POSIX_IOCTL | expand

Commit Message

Michal Rostecki Sept. 6, 2024, 12:46 p.m. UTC
Lack of this check leads to issues on musl-based system. Even though
compilation of libv4l2 itself with musl doesn't cause any errors,
using the library inside gst-plugins-v4l2 causes a compiler error
due to mismatch of the ioctl signature.

A similar check is already performed in v4l2convert.c, so the change
doesn't bring any inconsistency.

Link: https://bugs.gentoo.org/896418
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
---
 lib/include/libv4l2.h | 4 ++++
 lib/libv4l2/libv4l2.c | 4 ++++
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/lib/include/libv4l2.h b/lib/include/libv4l2.h
index ea1870db..16565555 100644
--- a/lib/include/libv4l2.h
+++ b/lib/include/libv4l2.h
@@ -63,7 +63,11 @@  LIBV4L_PUBLIC extern FILE *v4l2_log_file;
 LIBV4L_PUBLIC int v4l2_open(const char *file, int oflag, ...);
 LIBV4L_PUBLIC int v4l2_close(int fd);
 LIBV4L_PUBLIC int v4l2_dup(int fd);
+#ifdef HAVE_POSIX_IOCTL
+LIBV4L_PUBLIC int v4l2_ioctl(int fd, int request, ...);
+#else
 LIBV4L_PUBLIC int v4l2_ioctl(int fd, unsigned long int request, ...);
+#endif
 LIBV4L_PUBLIC ssize_t v4l2_read(int fd, void *buffer, size_t n);
 LIBV4L_PUBLIC ssize_t v4l2_write(int fd, const void *buffer, size_t n);
 LIBV4L_PUBLIC void *v4l2_mmap(void *start, size_t length, int prot, int flags,
diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
index 032a4f1c..1607ec35 100644
--- a/lib/libv4l2/libv4l2.c
+++ b/lib/libv4l2/libv4l2.c
@@ -1051,7 +1051,11 @@  static int v4l2_s_fmt(int index, struct v4l2_format *dest_fmt)
 	return 0;
 }
 
+#ifdef HAVE_POSIX_IOCTL
+int v4l2_ioctl(int fd, int request, ...)
+#else
 int v4l2_ioctl(int fd, unsigned long int request, ...)
+#endif
 {
 	void *arg;
 	va_list ap;