From 43622119bba9155f871d2436f45c722c62a34a61 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 28 Aug 2019 15:19:54 +1000 Subject: [PATCH] file/fdsrc: use struct stat64 on android to match stat64() Fixes android werror failures: ../plugins/elements/gstfdsrc.c:244:25: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types] if (fstat (src->fd, &stat_results) < 0) ^~~~~~~~~~~~~ /home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21); ^ ../plugins/elements/gstfdsrc.c:560:23: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types] if (fstat (src->fd, &stat_results) < 0) ^~~~~~~~~~~~~ /home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21); ^ if (fstat (fd, &stat_results) < 0) ^~~~~~~~~~~~~ /home/matt/Projects/cerbero/build/android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21); ^ if (fstat (src->fd, &stat_results) < 0) ^~~~~~~~~~~~~ ../../../../../android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21); ^ ../plugins/elements/gstfilesrc.c:477:23: error: incompatible pointer types passing 'struct stat *' to parameter of type 'struct stat64 *' [-Werror,-Wincompatible-pointer-types] if (fstat (src->fd, &stat_results) < 0) ^~~~~~~~~~~~~ ../../../../../android-ndk-18/sysroot/usr/include/sys/stat.h:159:38: note: passing argument to parameter '__buf' here int fstat64(int __fd, struct stat64* __buf) __RENAME_STAT64(fstat, 3, 21); ^ --- plugins/elements/gstfdsink.c | 6 +++++- plugins/elements/gstfdsrc.c | 8 ++++++-- plugins/elements/gstfilesrc.c | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/elements/gstfdsink.c b/plugins/elements/gstfdsink.c index 8f9996f293..be5ae28d41 100644 --- a/plugins/elements/gstfdsink.c +++ b/plugins/elements/gstfdsink.c @@ -69,10 +69,14 @@ #define off_t guint64 #endif +#define struct_stat struct stat + #if defined(__BIONIC__) /* Android */ #if defined(__ANDROID_API__) && __ANDROID_API__ >= 21 #undef fstat #define fstat fstat64 +#undef struct_stat +#define struct_stat struct stat64 #endif #endif @@ -327,7 +331,7 @@ gst_fd_sink_render (GstBaseSink * bsink, GstBuffer * buffer) static gboolean gst_fd_sink_check_fd (GstFdSink * fdsink, int fd, GError ** error) { - struct stat stat_results; + struct_stat stat_results; off_t result; /* see that it is a valid file descriptor */ diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c index e08e90d88e..77017e2775 100644 --- a/plugins/elements/gstfdsrc.c +++ b/plugins/elements/gstfdsrc.c @@ -80,10 +80,14 @@ #include "gstfdsrc.h" +#define struct_stat struct stat + #ifdef __BIONIC__ /* Android */ #if defined(__ANDROID_API__) && __ANDROID_API__ >= 21 #undef fstat #define fstat fstat64 +#undef struct_stat +#define struct_stat struct stat64 #endif #endif @@ -208,7 +212,7 @@ gst_fd_src_dispose (GObject * obj) static void gst_fd_src_update_fd (GstFdSrc * src, guint64 size) { - struct stat stat_results; + struct_stat stat_results; GST_DEBUG_OBJECT (src, "fdset %p, old_fd %d, new_fd %d", src->fdset, src->fd, src->new_fd); @@ -544,7 +548,7 @@ static gboolean gst_fd_src_get_size (GstBaseSrc * bsrc, guint64 * size) { GstFdSrc *src = GST_FD_SRC (bsrc); - struct stat stat_results; + struct_stat stat_results; if (src->size != -1) { *size = src->size; diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index 76ab12cb4d..d7888aeffe 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -65,10 +65,14 @@ # include #endif +#define struct_stat struct stat + #ifdef __BIONIC__ /* Android */ #if defined(__ANDROID_API__) && __ANDROID_API__ >= 21 #undef fstat #define fstat fstat64 +#undef struct_stat +#define struct_stat struct stat64 #endif #endif @@ -430,7 +434,7 @@ gst_file_src_is_seekable (GstBaseSrc * basesrc) static gboolean gst_file_src_get_size (GstBaseSrc * basesrc, guint64 * size) { - struct stat stat_results; + struct_stat stat_results; GstFileSrc *src; src = GST_FILE_SRC (basesrc); @@ -460,7 +464,7 @@ static gboolean gst_file_src_start (GstBaseSrc * basesrc) { GstFileSrc *src = GST_FILE_SRC (basesrc); - struct stat stat_results; + struct_stat stat_results; if (src->filename == NULL || src->filename[0] == '\0') goto no_filename;