plug-ins: fix various other warnings on the Windows build CI.

1 > warning: "_WIN32_WINNT" redefined
2 > pointer targets in passing argument 2 of 'send' differ in signedness
3 > passing argument 4 of 'setsockopt' from incompatible pointer type

For the signedness/type issues, I just casted to (void *) which was the
expected type for these parameter on the Linux API anyway. As for
Windows API (which was expecting char* for these various API), the
compiler just does the cast itself from void* without complaining
anymore.
This commit is contained in:
Jehan
2020-04-17 14:42:25 +02:00
parent e854de73ee
commit c280cb9da7

View File

@ -35,11 +35,14 @@
#include <glib.h> #include <glib.h>
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0502 #define _WIN32_WINNT 0x0502
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
typedef short sa_family_t; /* Not defined by winsock */ typedef short sa_family_t; /* Not defined by winsock */
#ifndef AI_ADDRCONFIG #ifndef AI_ADDRCONFIG
/* Missing from mingw headers, but value is publicly documented /* Missing from mingw headers, but value is publicly documented
@ -586,7 +589,7 @@ execute_command (SFCommand *cmd)
/* Write the response to the client */ /* Write the response to the client */
for (i = 0; i < RESPONSE_HEADER; i++) for (i = 0; i < RESPONSE_HEADER; i++)
if (cmd->filedes > 0 && send (cmd->filedes, buffer + i, 1, 0) < 0) if (cmd->filedes > 0 && send (cmd->filedes, (const void *) (buffer + i), 1, 0) < 0)
{ {
/* Write error */ /* Write error */
print_socket_api_error ("send"); print_socket_api_error ("send");
@ -620,7 +623,7 @@ read_from_client (gint filedes)
for (i = 0; i < COMMAND_HEADER;) for (i = 0; i < COMMAND_HEADER;)
{ {
nbytes = recv (filedes, buffer + i, COMMAND_HEADER - i, 0); nbytes = recv (filedes, (void *) (buffer + i), COMMAND_HEADER - i, 0);
if (nbytes < 0) if (nbytes < 0)
{ {
@ -724,14 +727,14 @@ make_socket (const struct addrinfo *ai)
gimp_quit (); gimp_quit ();
} }
setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(v)); setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (const void *) &v, sizeof(v));
#ifdef IPV6_V6ONLY #ifdef IPV6_V6ONLY
/* Only listen on IPv6 addresses, otherwise bind() will fail. */ /* Only listen on IPv6 addresses, otherwise bind() will fail. */
if (ai->ai_family == AF_INET6) if (ai->ai_family == AF_INET6)
{ {
v = 1; v = 1;
if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, &v, sizeof(v)) < 0) if (setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (const void *) &v, sizeof(v)) < 0)
{ {
print_socket_api_error ("setsockopt"); print_socket_api_error ("setsockopt");
gimp_quit(); gimp_quit();