changeset 39795:ecc02d9772ef

Avoid -Wcast-function-type warnings from casts after GetProcAddress. Reported by Andy Moreton <andrewjmoreton@gmail.com> in <https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>. Solution proposed by Eli Zaretskii. * lib/getaddrinfo.c (GetProcAddress): Cast result to 'void *' first. * lib/gettimeofday.c (GetProcAddress): Likewise. * lib/link.c (GetProcAddress): Likewise. * lib/physmem.c (GetProcAddress): Likewise. * lib/poll.c (GetProcAddress): Likewise. * lib/select.c (GetProcAddress): Likewise. * lib/stat-w32.c (GetProcAddress): Likewise.
author Bruno Haible <bruno@clisp.org>
date Sat, 18 Aug 2018 23:26:06 +0200
parents de44beeb728b
children 1a533aabdce0
files ChangeLog lib/getaddrinfo.c lib/gettimeofday.c lib/link.c lib/physmem.c lib/poll.c lib/select.c lib/stat-w32.c
diffstat 8 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Aug 18 23:32:14 2018 +0200
+++ b/ChangeLog	Sat Aug 18 23:26:06 2018 +0200
@@ -1,3 +1,17 @@
+2018-08-18  Bruno Haible  <bruno@clisp.org>
+
+	Avoid -Wcast-function-type warnings from casts after GetProcAddress.
+	Reported by Andy Moreton <andrewjmoreton@gmail.com> in
+	<https://lists.gnu.org/archive/html/emacs-devel/2018-08/msg00468.html>.
+	Solution proposed by Eli Zaretskii.
+	* lib/getaddrinfo.c (GetProcAddress): Cast result to 'void *' first.
+	* lib/gettimeofday.c (GetProcAddress): Likewise.
+	* lib/link.c (GetProcAddress): Likewise.
+	* lib/physmem.c (GetProcAddress): Likewise.
+	* lib/poll.c (GetProcAddress): Likewise.
+	* lib/select.c (GetProcAddress): Likewise.
+	* lib/stat-w32.c (GetProcAddress): Likewise.
+
 2018-08-18  Bruno Haible  <bruno@clisp.org>
 
 	glob: Fix another compilation error when glob.h is not replaced.
--- a/lib/getaddrinfo.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/getaddrinfo.c	Sat Aug 18 23:26:06 2018 +0200
@@ -62,6 +62,11 @@
 #include "sockets.h"
 
 #ifdef WINDOWS_NATIVE
+
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
                                         const struct addrinfo*,
                                         struct addrinfo**);
--- a/lib/gettimeofday.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/gettimeofday.c	Sat Aug 18 23:26:06 2018 +0200
@@ -33,6 +33,10 @@
 
 #ifdef WINDOWS_NATIVE
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 /* GetSystemTimePreciseAsFileTime was introduced only in Windows 8.  */
 typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
 static GetSystemTimePreciseAsFileTimeFuncType GetSystemTimePreciseAsFileTimeFunc = NULL;
--- a/lib/link.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/link.c	Sat Aug 18 23:26:06 2018 +0200
@@ -30,6 +30,10 @@
 #  define WIN32_LEAN_AND_MEAN
 #  include <windows.h>
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#  define GetProcAddress \
+    (void *) GetProcAddress
+
 /* CreateHardLink was introduced only in Windows 2000.  */
 typedef BOOL (WINAPI * CreateHardLinkFuncType) (LPCTSTR lpFileName,
                                                 LPCTSTR lpExistingFileName,
--- a/lib/physmem.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/physmem.c	Sat Aug 18 23:26:06 2018 +0200
@@ -59,8 +59,14 @@
 #endif
 
 #ifdef _WIN32
+
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
+
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 /*  MEMORYSTATUSEX is missing from older windows headers, so define
     a local replacement.  */
 typedef struct
@@ -76,6 +82,7 @@
   DWORDLONG ullAvailExtendedVirtual;
 } lMEMORYSTATUSEX;
 typedef WINBOOL (WINAPI *PFN_MS_EX) (lMEMORYSTATUSEX*);
+
 #endif
 
 #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
--- a/lib/poll.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/poll.c	Sat Aug 18 23:26:06 2018 +0200
@@ -84,6 +84,10 @@
    of SOCKETs, not bit masks of FDs.  */
 # undef select
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+# define GetProcAddress \
+   (void *) GetProcAddress
+
 static BOOL IsConsoleHandle (HANDLE h)
 {
   DWORD mode;
--- a/lib/select.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/select.c	Sat Aug 18 23:26:06 2018 +0200
@@ -47,6 +47,10 @@
 
 #undef select
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#define GetProcAddress \
+  (void *) GetProcAddress
+
 struct bitset {
   unsigned char in[FD_SETSIZE / CHAR_BIT];
   unsigned char out[FD_SETSIZE / CHAR_BIT];
--- a/lib/stat-w32.c	Sat Aug 18 23:32:14 2018 +0200
+++ b/lib/stat-w32.c	Sat Aug 18 23:26:06 2018 +0200
@@ -38,6 +38,10 @@
 #include "pathmax.h"
 #include "verify.h"
 
+/* Avoid warnings from gcc -Wcast-function-type.  */
+#define GetProcAddress \
+  (void *) GetProcAddress
+
 #if _GL_WINDOWS_STAT_INODES == 2
 /* GetFileInformationByHandleEx was introduced only in Windows Vista.  */
 typedef DWORD (WINAPI * GetFileInformationByHandleExFuncType) (HANDLE hFile,