Skip to contentSkip to conversation

libv4l2: Guard the v4l2_ioctl function with HAVE_POSIX_IOCTL

PATCH New Michal Rostecki 1 participant 1 message Sep 6, 2024 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libv4l2: Guard the v4l2_ioctl function with HAVE_POSIX_IOCTL

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.

---
 lib/include/libv4l2.h | 4 ++++
 lib/libv4l2/libv4l2.c | 4 ++++
 2 files changed, 8 insertions(+)
lib/include/libv4l2.h +4 -0
index ea1870db..16565555 100644
@@ -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,
lib/libv4l2/libv4l2.c +4 -0
index 032a4f1c..1607ec35 100644
@@ -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;
Signature · 1 line
2.44.2