]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix compiler warnings in w32.c
authorEli Zaretskii <eliz@gnu.org>
Thu, 26 Nov 2015 17:53:47 +0000 (19:53 +0200)
committerEli Zaretskii <eliz@gnu.org>
Thu, 26 Nov 2015 17:53:47 +0000 (19:53 +0200)
* src/w32.c (sys_socket): In case of error, use -1 as return
value, not INVALID_SOCKET, which causes compiler warnings.
(maybe_load_unicows_dll): Cast the return value of GetProcAddress
to the appropriate function signature, to avoid compiler errors.
Reported by Andy Moreton <andrewjmoreton@gmail.com>.  (Bug#21953)

src/w32.c
src/w32.h

index 9601012acd6a1564885454521ba8c8fa48fdfd3b..9b1d94de7862f359bd50ab1ab2b77a02f0027dfa 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -7432,7 +7432,7 @@ sys_socket (int af, int type, int protocol)
   if (winsock_lib == NULL)
     {
       errno = ENETDOWN;
-      return INVALID_SOCKET;
+      return -1;
     }
 
   check_errno ();
@@ -9270,8 +9270,10 @@ maybe_load_unicows_dll (void)
             pointers, and assign the correct addresses to these
             pointers at program startup (see emacs.c, which calls
             this function early on).  */
-         pMultiByteToWideChar = GetProcAddress (ret, "MultiByteToWideChar");
-         pWideCharToMultiByte = GetProcAddress (ret, "WideCharToMultiByte");
+         pMultiByteToWideChar =
+           (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar");
+         pWideCharToMultiByte =
+           (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte");
          return ret;
        }
       else
index 2c711502593aff9f4247b845f7d0b80ca573b8db..1efd562eadbfa9c874e016d1b191f0ce442abdf2 100644 (file)
--- a/src/w32.h
+++ b/src/w32.h
@@ -179,8 +179,10 @@ extern int _sys_wait_connect (int fd);
 
 extern HMODULE w32_delayed_load (Lisp_Object);
 
-extern int (WINAPI *pMultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int);
-extern int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL);
+typedef int (WINAPI *MultiByteToWideChar_Proc)(UINT,DWORD,LPCSTR,int,LPWSTR,int);
+typedef int (WINAPI *WideCharToMultiByte_Proc)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL);
+extern MultiByteToWideChar_Proc pMultiByteToWideChar;
+extern WideCharToMultiByte_Proc pWideCharToMultiByte;
 
 extern void init_environment (char **);
 extern void check_windows_init_file (void);