Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit860be17

Browse files
committed
Assorted minor changes to silence Windows compiler warnings.
Mostly to do with macro redefinitions or object signedness.
1 parent7762288 commit860be17

File tree

10 files changed

+44
-16
lines changed

10 files changed

+44
-16
lines changed

‎src/backend/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ get_current_username(const char *progname)
392392
/* Allocate new memory because later getpwuid() calls can overwrite it. */
393393
returnstrdup(pw->pw_name);
394394
#else
395-
longnamesize=256/* UNLEN */+1;
395+
unsignedlongnamesize=256/* UNLEN */+1;
396396
char*name;
397397

398398
name=malloc(namesize);

‎src/backend/port/win32/socket.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,18 @@ pgwin32_recv(SOCKET s, char *buf, int len, int f)
369369
return-1;
370370
}
371371

372+
/*
373+
* The second argument to send() is defined by SUS to be a "const void *"
374+
* and so we use the same signature here to keep compilers happy when
375+
* handling callers.
376+
*
377+
* But the buf member of a WSABUF struct is defined as "char *", so we cast
378+
* the second argument to that here when assigning it, also to keep compilers
379+
* happy.
380+
*/
381+
372382
int
373-
pgwin32_send(SOCKETs,char*buf,intlen,intflags)
383+
pgwin32_send(SOCKETs,constvoid*buf,intlen,intflags)
374384
{
375385
WSABUFwbuf;
376386
intr;
@@ -380,7 +390,7 @@ pgwin32_send(SOCKET s, char *buf, int len, int flags)
380390
return-1;
381391

382392
wbuf.len=len;
383-
wbuf.buf=buf;
393+
wbuf.buf=(char*)buf;
384394

385395
/*
386396
* Readiness of socket to send data to UDP socket may be not true: socket

‎src/backend/utils/adt/pg_locale.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,16 @@
6363
#include"utils/syscache.h"
6464

6565
#ifdefWIN32
66+
/*
67+
* This Windows file defines StrNCpy. We don't need it here, so we undefine
68+
* it to keep the compiler quiet, and undefine it again after the file is
69+
* included, so we don't accidentally use theirs.
70+
*/
71+
#undef StrNCpy
6672
#include<shlwapi.h>
73+
#ifdefStrNCpy
74+
#undef STrNCpy
75+
#endif
6776
#endif
6877

6978
#defineMAX_L10N_DATA80
@@ -555,7 +564,9 @@ strftime_win32(char *dst, size_t dstlen, const wchar_t *format, const struct tm
555564
dst[len]='\0';
556565
if (encoding!=PG_UTF8)
557566
{
558-
char*convstr=pg_do_encoding_conversion(dst,len,PG_UTF8,encoding);
567+
char*convstr=
568+
(char*)pg_do_encoding_conversion((unsignedchar*)dst,
569+
len,PG_UTF8,encoding);
559570

560571
if (dst!=convstr)
561572
{

‎src/bin/initdb/initdb.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ normalize_locale_name(char *new, const char *old)
15611561
staticvoid
15621562
setup_collation(void)
15631563
{
1564-
#ifdefHAVE_LOCALE_T
1564+
#if defined(HAVE_LOCALE_T)&& !defined(WIN32)
15651565
inti;
15661566
FILE*locale_a_handle;
15671567
charlocalebuf[NAMEDATALEN];
@@ -1687,10 +1687,10 @@ setup_collation(void)
16871687
printf(_("No usable system locales were found.\n"));
16881688
printf(_("Use the option \"--debug\" to see details.\n"));
16891689
}
1690-
#else/* not HAVE_LOCALE_T */
1690+
#else/* not HAVE_LOCALE_T&& not WIN32*/
16911691
printf(_("not supported on this platform\n"));
16921692
fflush(stdout);
1693-
#endif/* not HAVE_LOCALE_T */
1693+
#endif/* not HAVE_LOCALE_T && not WIN32*/
16941694
}
16951695

16961696
/*
@@ -2387,7 +2387,10 @@ setlocales(void)
23872387
#ifdefWIN32
23882388
typedefBOOL (WINAPI*__CreateRestrictedToken) (HANDLE,DWORD,DWORD,PSID_AND_ATTRIBUTES,DWORD,PLUID_AND_ATTRIBUTES,DWORD,PSID_AND_ATTRIBUTES,PHANDLE);
23892389

2390+
/* Windows API define missing from some versions of MingW headers */
2391+
#ifndefDISABLE_MAX_PRIVILEGE
23902392
#defineDISABLE_MAX_PRIVILEGE0x1
2393+
#endif
23912394

23922395
/*
23932396
* Create a restricted token and execute the specified process with it.

‎src/bin/pg_ctl/pg_ctl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,10 @@ typedef BOOL (WINAPI * __SetInformationJobObject) (HANDLE, JOBOBJECTINFOCLASS, L
14611461
typedefBOOL (WINAPI*__AssignProcessToJobObject) (HANDLE,HANDLE);
14621462
typedefBOOL (WINAPI*__QueryInformationJobObject) (HANDLE,JOBOBJECTINFOCLASS,LPVOID,DWORD,LPDWORD);
14631463

1464-
/* Windows API define missing from MingW headers */
1464+
/* Windows API define missing from some versions of MingW headers */
1465+
#ifndefDISABLE_MAX_PRIVILEGE
14651466
#defineDISABLE_MAX_PRIVILEGE0x1
1467+
#endif
14661468

14671469
/*
14681470
* Create a restricted token, a job object sandbox, and execute the specified

‎src/include/port/win32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ SOCKETpgwin32_accept(SOCKET s, struct sockaddr * addr, int *addrlen);
336336
intpgwin32_connect(SOCKETs,conststructsockaddr*name,intnamelen);
337337
intpgwin32_select(intnfds,fd_set*readfs,fd_set*writefds,fd_set*exceptfds,conststructtimeval*timeout);
338338
intpgwin32_recv(SOCKETs,char*buf,intlen,intflags);
339-
intpgwin32_send(SOCKETs,char*buf,intlen,intflags);
339+
intpgwin32_send(SOCKETs,constvoid*buf,intlen,intflags);
340340

341341
constchar*pgwin32_socket_strerror(interr);
342342
intpgwin32_waitforsinglesocket(SOCKETs,intwhat,inttimeout);

‎src/pl/plperl/plperl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,7 +3551,7 @@ hv_store_string(HV *hv, const char *key, SV *val)
35513551
* does not appear that hashes track UTF-8-ness of keys at all in Perl
35523552
* 5.6.
35533553
*/
3554-
hlen=-strlen(hkey);
3554+
hlen=- (int)strlen(hkey);
35553555
ret=hv_store(hv,hkey,hlen,val,0);
35563556

35573557
if (hkey!=key)
@@ -3576,7 +3576,7 @@ hv_fetch_string(HV *hv, const char *key)
35763576
GetDatabaseEncoding(),PG_UTF8);
35773577

35783578
/* See notes in hv_store_string */
3579-
hlen=-strlen(hkey);
3579+
hlen=- (int)strlen(hkey);
35803580
ret=hv_fetch(hv,hkey,hlen,0);
35813581

35823582
if (hkey!=key)

‎src/port/noblock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pg_set_noblock(pgsocket sock)
2323
#if !defined(WIN32)
2424
return (fcntl(sock,F_SETFL,O_NONBLOCK)!=-1);
2525
#else
26-
longioctlsocket_ret=1;
26+
unsignedlongioctlsocket_ret=1;
2727

2828
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
2929
return (ioctlsocket(sock,FIONBIO,&ioctlsocket_ret)==0);
@@ -42,7 +42,7 @@ pg_set_block(pgsocket sock)
4242
return false;
4343
return true;
4444
#else
45-
longioctlsocket_ret=0;
45+
unsignedlongioctlsocket_ret=0;
4646

4747
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
4848
return (ioctlsocket(sock,FIONBIO,&ioctlsocket_ret)==0);

‎src/test/regress/pg_regress.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ __attribute__((format(printf, 2, 3)));
140140
#ifdefWIN32
141141
typedefBOOL (WINAPI*__CreateRestrictedToken) (HANDLE,DWORD,DWORD,PSID_AND_ATTRIBUTES,DWORD,PLUID_AND_ATTRIBUTES,DWORD,PSID_AND_ATTRIBUTES,PHANDLE);
142142

143-
/* Windows API define missing from MingW headers */
143+
/* Windows API define missing from some versions of MingW headers */
144+
#ifndefDISABLE_MAX_PRIVILEGE
144145
#defineDISABLE_MAX_PRIVILEGE0x1
145146
#endif
147+
#endif
146148

147149
/*
148150
* allow core files if possible.

‎src/timezone/pgtz.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ identify_system_timezone(void)
11581158

11591159
memset(zonename,0,sizeof(zonename));
11601160
namesize=sizeof(zonename);
1161-
if ((r=RegQueryValueEx(key,"Std",NULL,NULL,zonename,&namesize))!=ERROR_SUCCESS)
1161+
if ((r=RegQueryValueEx(key,"Std",NULL,NULL,(unsignedchar*)zonename,&namesize))!=ERROR_SUCCESS)
11621162
{
11631163
ereport(LOG,
11641164
(errmsg_internal("could not query value for key \"std\" to identify system time zone \"%s\": %i",
@@ -1175,7 +1175,7 @@ identify_system_timezone(void)
11751175
}
11761176
memset(zonename,0,sizeof(zonename));
11771177
namesize=sizeof(zonename);
1178-
if ((r=RegQueryValueEx(key,"Dlt",NULL,NULL,zonename,&namesize))!=ERROR_SUCCESS)
1178+
if ((r=RegQueryValueEx(key,"Dlt",NULL,NULL,(unsignedchar*)zonename,&namesize))!=ERROR_SUCCESS)
11791179
{
11801180
ereport(LOG,
11811181
(errmsg_internal("could not query value for key \"dlt\" to identify system time zone \"%s\": %i",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp