Skip to content

Commit 0f44335

Browse files
committed
Miscellaneous cleanup to silence compiler warnings seen on Mingw.
Remove some dead code, conditionally declare some items or call some code, and fix one or two declarations.
1 parent 8e461ca commit 0f44335

File tree

9 files changed

+35
-37
lines changed

9 files changed

+35
-37
lines changed

src/backend/executor/nodeBitmapHeapscan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ BitmapHeapNext(BitmapHeapScanState *node)
6666
TIDBitmap *tbm;
6767
TBMIterator *tbmiterator;
6868
TBMIterateResult *tbmres;
69+
#ifdef USE_PREFETCH
6970
TBMIterator *prefetch_iterator;
71+
#endif
7072
OffsetNumber targoffset;
7173
TupleTableSlot *slot;
7274

@@ -79,7 +81,9 @@ BitmapHeapNext(BitmapHeapScanState *node)
7981
tbm = node->tbm;
8082
tbmiterator = node->tbmiterator;
8183
tbmres = node->tbmres;
84+
#ifdef USE_PREFETCH
8285
prefetch_iterator = node->prefetch_iterator;
86+
#endif
8387

8488
/*
8589
* If we haven't yet performed the underlying index scan, do it, and begin

src/backend/utils/adt/formatting.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,9 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
15541554
#endif /* USE_WIDE_UPPER_LOWER */
15551555
else
15561556
{
1557+
#ifdef HAVE_LOCALE_T
15571558
pg_locale_t mylocale = 0;
1559+
#endif
15581560
char *p;
15591561

15601562
if (collid != DEFAULT_COLLATION_OID)
@@ -1570,7 +1572,9 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
15701572
errmsg("could not determine which collation to use for lower() function"),
15711573
errhint("Use the COLLATE clause to set the collation explicitly.")));
15721574
}
1575+
#ifdef HAVE_LOCALE_T
15731576
mylocale = pg_newlocale_from_collation(collid);
1577+
#endif
15741578
}
15751579

15761580
result = pnstrdup(buff, nbytes);
@@ -1675,7 +1679,9 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
16751679
#endif /* USE_WIDE_UPPER_LOWER */
16761680
else
16771681
{
1682+
#ifdef HAVE_LOCALE_T
16781683
pg_locale_t mylocale = 0;
1684+
#endif
16791685
char *p;
16801686

16811687
if (collid != DEFAULT_COLLATION_OID)
@@ -1691,7 +1697,9 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
16911697
errmsg("could not determine which collation to use for upper() function"),
16921698
errhint("Use the COLLATE clause to set the collation explicitly.")));
16931699
}
1700+
#ifdef HAVE_LOCALE_T
16941701
mylocale = pg_newlocale_from_collation(collid);
1702+
#endif
16951703
}
16961704

16971705
result = pnstrdup(buff, nbytes);
@@ -1820,7 +1828,9 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
18201828
#endif /* USE_WIDE_UPPER_LOWER */
18211829
else
18221830
{
1831+
#ifdef HAVE_LOCALE_T
18231832
pg_locale_t mylocale = 0;
1833+
#endif
18241834
char *p;
18251835

18261836
if (collid != DEFAULT_COLLATION_OID)
@@ -1836,7 +1846,9 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
18361846
errmsg("could not determine which collation to use for initcap() function"),
18371847
errhint("Use the COLLATE clause to set the collation explicitly.")));
18381848
}
1849+
#ifdef HAVE_LOCALE_T
18391850
mylocale = pg_newlocale_from_collation(collid);
1851+
#endif
18401852
}
18411853

18421854
result = pnstrdup(buff, nbytes);

src/backend/utils/adt/varlena.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,9 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid)
12991299
char a2buf[STACKBUFLEN];
13001300
char *a1p,
13011301
*a2p;
1302+
#ifdef HAVE_LOCALE_T
13021303
pg_locale_t mylocale = 0;
1304+
#endif
13031305

13041306
if (collid != DEFAULT_COLLATION_OID)
13051307
{
@@ -1314,7 +1316,9 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2, Oid collid)
13141316
errmsg("could not determine which collation to use for string comparison"),
13151317
errhint("Use the COLLATE clause to set the collation explicitly.")));
13161318
}
1319+
#ifdef HAVE_LOCALE_T
13171320
mylocale = pg_newlocale_from_collation(collid);
1321+
#endif
13181322
}
13191323

13201324
#ifdef WIN32

src/bin/initdb/initdb.c

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,29 +2277,6 @@ check_locale_encoding(const char *locale, int user_enc)
22772277
return true;
22782278
}
22792279

2280-
#ifdef WIN32
2281-
2282-
/*
2283-
* Replace 'needle' with 'replacement' in 'str' . Note that the replacement
2284-
* is done in-place, so 'replacement' must be shorter than 'needle'.
2285-
*/
2286-
static void
2287-
strreplace(char *str, char *needle, char *replacement)
2288-
{
2289-
char *s;
2290-
2291-
s = strstr(str, needle);
2292-
if (s != NULL)
2293-
{
2294-
int replacementlen = strlen(replacement);
2295-
char *rest = s + strlen(needle);
2296-
2297-
memcpy(s, replacement, replacementlen);
2298-
memmove(s + replacementlen, rest, strlen(rest) + 1);
2299-
}
2300-
}
2301-
#endif /* WIN32 */
2302-
23032280
/*
23042281
* set up the locale variables
23052282
*

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ static pid_t bgchild = -1;
6363

6464
/* End position for xlog streaming, empty string if unknown yet */
6565
static XLogRecPtr xlogendptr;
66+
#ifndef WIN32
6667
static int has_xlogendptr = 0;
68+
#else
69+
static volatile LONG has_xlogendptr = 0;
70+
#endif
6771

6872
/* Function headers */
6973
static void usage(void);
@@ -1070,10 +1074,11 @@ BaseBackup(void)
10701074

10711075
if (bgchild > 0)
10721076
{
1073-
int status;
1074-
10751077
#ifndef WIN32
1078+
int status;
10761079
int r;
1080+
#else
1081+
DWORD status;
10771082
#endif
10781083

10791084
if (verbose)
@@ -1147,7 +1152,7 @@ BaseBackup(void)
11471152
if (status != 0)
11481153
{
11491154
fprintf(stderr, _("%s: child thread exited with error %u\n"),
1150-
progname, status);
1155+
progname, (unsigned int) status);
11511156
disconnect_and_exit(1);
11521157
}
11531158
/* Exited normally, we're happy */

src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,16 @@ StreamLog(void)
278278
* When sigint is called, just tell the system to exit at the next possible
279279
* moment.
280280
*/
281+
#ifndef WIN32
282+
281283
static void
282284
sigint_handler(int signum)
283285
{
284286
time_to_abort = true;
285287
}
286288

289+
#endif
290+
287291
int
288292
main(int argc, char **argv)
289293
{

src/bin/pg_ctl/pg_ctl.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,6 @@ pgwin32_ServiceMain(DWORD argc, LPTSTR *argv)
14141414
{
14151415
PROCESS_INFORMATION pi;
14161416
DWORD ret;
1417-
DWORD check_point_start;
14181417

14191418
/* Initialize variables */
14201419
status.dwWin32ExitCode = S_OK;
@@ -1459,12 +1458,6 @@ pgwin32_ServiceMain(DWORD argc, LPTSTR *argv)
14591458
write_eventlog(EVENTLOG_INFORMATION_TYPE, _("Server started and accepting connections\n"));
14601459
}
14611460

1462-
/*
1463-
* Save the checkpoint value as it might have been incremented in
1464-
* test_postmaster_connection
1465-
*/
1466-
check_point_start = status.dwCheckPoint;
1467-
14681461
pgwin32_SetServiceStatus(SERVICE_RUNNING);
14691462

14701463
/* Wait for quit... */

src/bin/pgevent/pgevent.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ HRESULT
4242
DllInstall(BOOL bInstall,
4343
LPCWSTR pszCmdLine)
4444
{
45-
size_t ret;
4645

4746
if (pszCmdLine && *pszCmdLine != '\0')
4847
wcstombs(event_source, pszCmdLine, sizeof(event_source));

src/interfaces/ecpg/pgtypeslib/timestamp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
130130
date0;
131131
double time;
132132
#endif
133-
time_t utime;
134-
135133
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
134+
time_t utime;
136135
struct tm *tx;
137136
#endif
138137

@@ -202,14 +201,15 @@ timestamp2tm(timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn)
202201
*/
203202
if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday))
204203
{
204+
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
205+
205206
#ifdef HAVE_INT64_TIMESTAMP
206207
utime = dt / USECS_PER_SEC +
207208
((date0 - date2j(1970, 1, 1)) * INT64CONST(86400));
208209
#else
209210
utime = dt + (date0 - date2j(1970, 1, 1)) * SECS_PER_DAY;
210211
#endif
211212

212-
#if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE)
213213
tx = localtime(&utime);
214214
tm->tm_year = tx->tm_year + 1900;
215215
tm->tm_mon = tx->tm_mon + 1;

0 commit comments

Comments
 (0)