mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Assorted minor changes to silence Windows compiler warnings.
Mostly to do with macro redefinitions or object signedness.
This commit is contained in:
parent
7762288744
commit
860be17ec3
@ -392,7 +392,7 @@ get_current_username(const char *progname)
|
|||||||
/* Allocate new memory because later getpwuid() calls can overwrite it. */
|
/* Allocate new memory because later getpwuid() calls can overwrite it. */
|
||||||
return strdup(pw->pw_name);
|
return strdup(pw->pw_name);
|
||||||
#else
|
#else
|
||||||
long namesize = 256 /* UNLEN */ + 1;
|
unsigned long namesize = 256 /* UNLEN */ + 1;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = malloc(namesize);
|
name = malloc(namesize);
|
||||||
|
@ -369,8 +369,18 @@ pgwin32_recv(SOCKET s, char *buf, int len, int f)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The second argument to send() is defined by SUS to be a "const void *"
|
||||||
|
* and so we use the same signature here to keep compilers happy when
|
||||||
|
* handling callers.
|
||||||
|
*
|
||||||
|
* But the buf member of a WSABUF struct is defined as "char *", so we cast
|
||||||
|
* the second argument to that here when assigning it, also to keep compilers
|
||||||
|
* happy.
|
||||||
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
pgwin32_send(SOCKET s, char *buf, int len, int flags)
|
pgwin32_send(SOCKET s, const void *buf, int len, int flags)
|
||||||
{
|
{
|
||||||
WSABUF wbuf;
|
WSABUF wbuf;
|
||||||
int r;
|
int r;
|
||||||
@ -380,7 +390,7 @@ pgwin32_send(SOCKET s, char *buf, int len, int flags)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
wbuf.len = len;
|
wbuf.len = len;
|
||||||
wbuf.buf = buf;
|
wbuf.buf = (char *) buf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Readiness of socket to send data to UDP socket may be not true: socket
|
* Readiness of socket to send data to UDP socket may be not true: socket
|
||||||
|
@ -63,7 +63,16 @@
|
|||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
/*
|
||||||
|
* This Windows file defines StrNCpy. We don't need it here, so we undefine
|
||||||
|
* it to keep the compiler quiet, and undefine it again after the file is
|
||||||
|
* included, so we don't accidentally use theirs.
|
||||||
|
*/
|
||||||
|
#undef StrNCpy
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
#ifdef StrNCpy
|
||||||
|
#undef STrNCpy
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_L10N_DATA 80
|
#define MAX_L10N_DATA 80
|
||||||
@ -555,7 +564,9 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm
|
|||||||
dst[len] = '\0';
|
dst[len] = '\0';
|
||||||
if (encoding != PG_UTF8)
|
if (encoding != PG_UTF8)
|
||||||
{
|
{
|
||||||
char *convstr = pg_do_encoding_conversion(dst, len, PG_UTF8, encoding);
|
char *convstr =
|
||||||
|
(char *) pg_do_encoding_conversion((unsigned char *) dst,
|
||||||
|
len, PG_UTF8, encoding);
|
||||||
|
|
||||||
if (dst != convstr)
|
if (dst != convstr)
|
||||||
{
|
{
|
||||||
|
@ -1561,7 +1561,7 @@ normalize_locale_name(char *new, const char *old)
|
|||||||
static void
|
static void
|
||||||
setup_collation(void)
|
setup_collation(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LOCALE_T
|
#if defined(HAVE_LOCALE_T) && !defined(WIN32)
|
||||||
int i;
|
int i;
|
||||||
FILE *locale_a_handle;
|
FILE *locale_a_handle;
|
||||||
char localebuf[NAMEDATALEN];
|
char localebuf[NAMEDATALEN];
|
||||||
@ -1687,10 +1687,10 @@ setup_collation(void)
|
|||||||
printf(_("No usable system locales were found.\n"));
|
printf(_("No usable system locales were found.\n"));
|
||||||
printf(_("Use the option \"--debug\" to see details.\n"));
|
printf(_("Use the option \"--debug\" to see details.\n"));
|
||||||
}
|
}
|
||||||
#else /* not HAVE_LOCALE_T */
|
#else /* not HAVE_LOCALE_T && not WIN32 */
|
||||||
printf(_("not supported on this platform\n"));
|
printf(_("not supported on this platform\n"));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#endif /* not HAVE_LOCALE_T */
|
#endif /* not HAVE_LOCALE_T && not WIN32*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2387,7 +2387,10 @@ setlocales(void)
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
|
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
|
||||||
|
|
||||||
|
/* Windows API define missing from some versions of MingW headers */
|
||||||
|
#ifndef DISABLE_MAX_PRIVILEGE
|
||||||
#define DISABLE_MAX_PRIVILEGE 0x1
|
#define DISABLE_MAX_PRIVILEGE 0x1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a restricted token and execute the specified process with it.
|
* Create a restricted token and execute the specified process with it.
|
||||||
|
@ -1461,8 +1461,10 @@ typedef BOOL (WINAPI * __SetInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, L
|
|||||||
typedef BOOL (WINAPI * __AssignProcessToJobObject) (HANDLE, HANDLE);
|
typedef BOOL (WINAPI * __AssignProcessToJobObject) (HANDLE, HANDLE);
|
||||||
typedef BOOL (WINAPI * __QueryInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
|
typedef BOOL (WINAPI * __QueryInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, LPVOID, DWORD, LPDWORD);
|
||||||
|
|
||||||
/* Windows API define missing from MingW headers */
|
/* Windows API define missing from some versions of MingW headers */
|
||||||
|
#ifndef DISABLE_MAX_PRIVILEGE
|
||||||
#define DISABLE_MAX_PRIVILEGE 0x1
|
#define DISABLE_MAX_PRIVILEGE 0x1
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a restricted token, a job object sandbox, and execute the specified
|
* Create a restricted token, a job object sandbox, and execute the specified
|
||||||
|
@ -336,7 +336,7 @@ SOCKET pgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
|
|||||||
int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
|
int pgwin32_connect(SOCKET s, const struct sockaddr * name, int namelen);
|
||||||
int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
|
int pgwin32_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *exceptfds, const struct timeval * timeout);
|
||||||
int pgwin32_recv(SOCKET s, char *buf, int len, int flags);
|
int pgwin32_recv(SOCKET s, char *buf, int len, int flags);
|
||||||
int pgwin32_send(SOCKET s, char *buf, int len, int flags);
|
int pgwin32_send(SOCKET s, const void *buf, int len, int flags);
|
||||||
|
|
||||||
const char *pgwin32_socket_strerror(int err);
|
const char *pgwin32_socket_strerror(int err);
|
||||||
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout);
|
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout);
|
||||||
|
@ -3551,7 +3551,7 @@ hv_store_string(HV *hv, const char *key, SV *val)
|
|||||||
* does not appear that hashes track UTF-8-ness of keys at all in Perl
|
* does not appear that hashes track UTF-8-ness of keys at all in Perl
|
||||||
* 5.6.
|
* 5.6.
|
||||||
*/
|
*/
|
||||||
hlen = -strlen(hkey);
|
hlen = - (int) strlen(hkey);
|
||||||
ret = hv_store(hv, hkey, hlen, val, 0);
|
ret = hv_store(hv, hkey, hlen, val, 0);
|
||||||
|
|
||||||
if (hkey != key)
|
if (hkey != key)
|
||||||
@ -3576,7 +3576,7 @@ hv_fetch_string(HV *hv, const char *key)
|
|||||||
GetDatabaseEncoding(), PG_UTF8);
|
GetDatabaseEncoding(), PG_UTF8);
|
||||||
|
|
||||||
/* See notes in hv_store_string */
|
/* See notes in hv_store_string */
|
||||||
hlen = -strlen(hkey);
|
hlen = - (int) strlen(hkey);
|
||||||
ret = hv_fetch(hv, hkey, hlen, 0);
|
ret = hv_fetch(hv, hkey, hlen, 0);
|
||||||
|
|
||||||
if (hkey != key)
|
if (hkey != key)
|
||||||
|
@ -23,7 +23,7 @@ pg_set_noblock(pgsocket sock)
|
|||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
return (fcntl(sock, F_SETFL, O_NONBLOCK) != -1);
|
return (fcntl(sock, F_SETFL, O_NONBLOCK) != -1);
|
||||||
#else
|
#else
|
||||||
long ioctlsocket_ret = 1;
|
unsigned long ioctlsocket_ret = 1;
|
||||||
|
|
||||||
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
|
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
|
||||||
return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
|
return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
|
||||||
@ -42,7 +42,7 @@ pg_set_block(pgsocket sock)
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
long ioctlsocket_ret = 0;
|
unsigned long ioctlsocket_ret = 0;
|
||||||
|
|
||||||
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
|
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
|
||||||
return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
|
return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0);
|
||||||
|
@ -140,9 +140,11 @@ __attribute__((format(printf, 2, 3)));
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
|
typedef BOOL (WINAPI * __CreateRestrictedToken) (HANDLE, DWORD, DWORD, PSID_AND_ATTRIBUTES, DWORD, PLUID_AND_ATTRIBUTES, DWORD, PSID_AND_ATTRIBUTES, PHANDLE);
|
||||||
|
|
||||||
/* Windows API define missing from MingW headers */
|
/* Windows API define missing from some versions of MingW headers */
|
||||||
|
#ifndef DISABLE_MAX_PRIVILEGE
|
||||||
#define DISABLE_MAX_PRIVILEGE 0x1
|
#define DISABLE_MAX_PRIVILEGE 0x1
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* allow core files if possible.
|
* allow core files if possible.
|
||||||
|
@ -1158,7 +1158,7 @@ identify_system_timezone(void)
|
|||||||
|
|
||||||
memset(zonename, 0, sizeof(zonename));
|
memset(zonename, 0, sizeof(zonename));
|
||||||
namesize = sizeof(zonename);
|
namesize = sizeof(zonename);
|
||||||
if ((r = RegQueryValueEx(key, "Std", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS)
|
if ((r = RegQueryValueEx(key, "Std", NULL, NULL, (unsigned char *) zonename, &namesize)) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errmsg_internal("could not query value for key \"std\" to identify system time zone \"%s\": %i",
|
(errmsg_internal("could not query value for key \"std\" to identify system time zone \"%s\": %i",
|
||||||
@ -1175,7 +1175,7 @@ identify_system_timezone(void)
|
|||||||
}
|
}
|
||||||
memset(zonename, 0, sizeof(zonename));
|
memset(zonename, 0, sizeof(zonename));
|
||||||
namesize = sizeof(zonename);
|
namesize = sizeof(zonename);
|
||||||
if ((r = RegQueryValueEx(key, "Dlt", NULL, NULL, zonename, &namesize)) != ERROR_SUCCESS)
|
if ((r = RegQueryValueEx(key, "Dlt", NULL, NULL, (unsigned char *) zonename, &namesize)) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errmsg_internal("could not query value for key \"dlt\" to identify system time zone \"%s\": %i",
|
(errmsg_internal("could not query value for key \"dlt\" to identify system time zone \"%s\": %i",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user