[vlc-commits] contrib: nfs: Patch win32_compat.h to not override snprintf
Martin Storsjö
git at videolan.org
Mon Mar 15 08:42:51 UTC 2021
vlc | branch: master | Martin Storsjö <martin at martin.st> | Sat Mar 13 13:06:49 2021 +0200| [970248c1e409b1fef0d8f50f97de6259c6f849a6] | committer: Martin Storsjö
contrib: nfs: Patch win32_compat.h to not override snprintf
Mingw toolchains always provide snprintf, and modern MSVC versions
do too.
The define of snprintf to sprintf_s is applied before stdio headers
are included, causing it to be applied to the headers themselves,
breaking mingw-w64 headers targeting UCRT (because the headers provide
declarations for both snprintf and sprintf_s, but one of them is
declared as a static inline while the other is not).
In upstream libnfs, this define was entirely commented out in
6564abaa1f979c0b62044f695030a32b60620163, so this backports one bit
of that commit.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=970248c1e409b1fef0d8f50f97de6259c6f849a6
---
contrib/src/nfs/mingw-snprintf.patch | 11 +++++++++++
contrib/src/nfs/rules.mak | 1 +
2 files changed, 12 insertions(+)
diff --git a/contrib/src/nfs/mingw-snprintf.patch b/contrib/src/nfs/mingw-snprintf.patch
new file mode 100644
index 0000000000..475f8d9764
--- /dev/null
+++ b/contrib/src/nfs/mingw-snprintf.patch
@@ -0,0 +1,11 @@
+--- nfs/include/win32/win32_compat.h.orig 2021-03-15 10:40:08.534061716 +0200
++++ nfs/include/win32/win32_compat.h 2021-03-15 10:40:54.088974157 +0200
+@@ -133,7 +133,7 @@
+
+ /* Wrapper macros to call misc. functions win32 is missing */
+ #define poll(x, y, z) win32_poll(x, y, z)
+-#define snprintf sprintf_s
++//#define snprintf sprintf_s
+ #define inet_pton(x,y,z) win32_inet_pton(x,y,z)
+ #define open(x, y, z) _open(x, y, z)
+ #ifndef lseek
diff --git a/contrib/src/nfs/rules.mak b/contrib/src/nfs/rules.mak
index b65816c37d..c880c5d142 100644
--- a/contrib/src/nfs/rules.mak
+++ b/contrib/src/nfs/rules.mak
@@ -15,6 +15,7 @@ $(TARBALLS)/libnfs-$(NFS_VERSION).tar.gz:
nfs: libnfs-$(NFS_VERSION).tar.gz .sum-nfs
$(UNPACK)
mv libnfs-libnfs-$(NFS_VERSION) libnfs-$(NFS_VERSION)
+ $(APPLY) $(SRC)/nfs/mingw-snprintf.patch
$(UPDATE_AUTOCONFIG)
$(MOVE)
More information about the vlc-commits
mailing list