gst-plugins-good1: fix build with gcc14 and musl ioctl type

This commit is contained in:
oreo639 2025-03-16 02:36:06 -07:00 committed by oreo639
parent c7f87762ff
commit 05e9fe2ae1

View file

@ -0,0 +1,62 @@
From dd1fc2b7931f5789815e17dda2ef7c31b9fba563 Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Tue, 11 Mar 2025 16:36:58 +0100
Subject: [PATCH] v4l2object: fix type mismatch when ioctl takes int
v4l2object->ioctl can either be set to v4l2_ioctl() or ioctl().
v4l2_ioctl() always takes the request number as unsigned long int, but ioctl()
may take (at least) unsigned long int, int, or unsigned, depending on libc.
This means that there isn't one function pointer type that can be used for
v4l2object->ioctl that will always be able to accomodate being set to either of
v4l2_ioctl() and ioctl(). It's therefore necessary to wrap one of them so that
both options can have the same type. This fixes an assignment from incompatible
pointer type error when building for musl.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8613>
---
.../gst-plugins-good/sys/v4l2/gstv4l2object.c | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2object.c
index 288ff74477d7..5b7f45512459 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -528,6 +528,23 @@ v4l2_mmap_wrapper (gpointer start, gsize length, gint prot, gint flags, gint fd,
#define v4l2_mmap v4l2_mmap_wrapper
#endif /* SIZEOF_OFF_T < 8 */
+
+#if defined(__linux__) && !defined(__GLIBC__)
+/* v4l2_ioctl always takes request as unsigned long int, not ioctl_req_t */
+static gint
+v4l2_ioctl_wrapper (gint fd, ioctl_req_t request, ...)
+{
+ void *arg;
+ va_list ap;
+
+ va_start (ap, request);
+ arg = va_arg (ap, void *);
+ va_end (ap);
+
+ return v4l2_ioctl (fd, request, arg);
+}
+#endif /* defined(__linux__) && !defined(__GLIBC__) */
+
#endif /* HAVE_LIBV4L2 */
GstV4l2Object *
@@ -578,7 +595,11 @@ gst_v4l2_object_new (GstElement * element,
v4l2object->fd_open = v4l2_fd_open;
v4l2object->close = v4l2_close;
v4l2object->dup = v4l2_dup;
+#ifdef __GLIBC__
v4l2object->ioctl = v4l2_ioctl;
+#else
+ v4l2object->ioctl = v4l2_ioctl_wrapper;
+#endif
v4l2object->read = v4l2_read;
v4l2object->mmap = v4l2_mmap;
v4l2object->munmap = v4l2_munmap;
--
GitLab