Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 27a23f9

Browse files
committed
pg_ctl: Cast DWORD values to avoid -Wformat warnings.
This affects pg_ctl alone, because pg_ctl takes the exceptional step of calling Windows API functions in a Cygwin build.
1 parent 772945b commit 27a23f9

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/bin/pg_ctl/pg_ctl.c

+26-8
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,9 @@ pgwin32_doRegister(void)
14561456
NULL, NULL, "RPCSS\0", register_username, register_password)) == NULL)
14571457
{
14581458
CloseServiceHandle(hSCM);
1459-
write_stderr(_("%s: could not register service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
1459+
write_stderr(_("%s: could not register service \"%s\": error code %lu\n"),
1460+
progname, register_servicename,
1461+
(unsigned long) GetLastError());
14601462
exit(1);
14611463
}
14621464
CloseServiceHandle(hService);
@@ -1484,14 +1486,18 @@ pgwin32_doUnregister(void)
14841486
if ((hService = OpenService(hSCM, register_servicename, DELETE)) == NULL)
14851487
{
14861488
CloseServiceHandle(hSCM);
1487-
write_stderr(_("%s: could not open service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
1489+
write_stderr(_("%s: could not open service \"%s\": error code %lu\n"),
1490+
progname, register_servicename,
1491+
(unsigned long) GetLastError());
14881492
exit(1);
14891493
}
14901494
if (!DeleteService(hService))
14911495
{
14921496
CloseServiceHandle(hService);
14931497
CloseServiceHandle(hSCM);
1494-
write_stderr(_("%s: could not unregister service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
1498+
write_stderr(_("%s: could not unregister service \"%s\": error code %lu\n"),
1499+
progname, register_servicename,
1500+
(unsigned long) GetLastError());
14951501
exit(1);
14961502
}
14971503
CloseServiceHandle(hService);
@@ -1627,7 +1633,9 @@ pgwin32_doRunAsService(void)
16271633

16281634
if (StartServiceCtrlDispatcher(st) == 0)
16291635
{
1630-
write_stderr(_("%s: could not start service \"%s\": error code %lu\n"), progname, register_servicename, GetLastError());
1636+
write_stderr(_("%s: could not start service \"%s\": error code %lu\n"),
1637+
progname, register_servicename,
1638+
(unsigned long) GetLastError());
16311639
exit(1);
16321640
}
16331641
}
@@ -1708,7 +1716,14 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
17081716
/* Open the current token to use as a base for the restricted one */
17091717
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &origToken))
17101718
{
1711-
write_stderr(_("%s: could not open process token: error code %lu\n"), progname, GetLastError());
1719+
/*
1720+
* Most Windows targets make DWORD a 32-bit unsigned long. Cygwin
1721+
* x86_64, an LP64 target, makes it a 32-bit unsigned int. In code
1722+
* built for Cygwin as well as for native Windows targets, cast DWORD
1723+
* before printing.
1724+
*/
1725+
write_stderr(_("%s: could not open process token: error code %lu\n"),
1726+
progname, (unsigned long) GetLastError());
17121727
return 0;
17131728
}
17141729

@@ -1721,7 +1736,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
17211736
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
17221737
0, &dropSids[1].Sid))
17231738
{
1724-
write_stderr(_("%s: could not allocate SIDs: error code %lu\n"), progname, GetLastError());
1739+
write_stderr(_("%s: could not allocate SIDs: error code %lu\n"),
1740+
progname, (unsigned long) GetLastError());
17251741
return 0;
17261742
}
17271743

@@ -1740,7 +1756,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
17401756

17411757
if (!b)
17421758
{
1743-
write_stderr(_("%s: could not create restricted token: error code %lu\n"), progname, GetLastError());
1759+
write_stderr(_("%s: could not create restricted token: error code %lu\n"),
1760+
progname, (unsigned long) GetLastError());
17441761
return 0;
17451762
}
17461763

@@ -1791,7 +1808,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
17911808
HANDLE job;
17921809
char jobname[128];
17931810

1794-
sprintf(jobname, "PostgreSQL_%lu", processInfo->dwProcessId);
1811+
sprintf(jobname, "PostgreSQL_%lu",
1812+
(unsigned long) processInfo->dwProcessId);
17951813

17961814
job = _CreateJobObject(NULL, jobname);
17971815
if (job)

0 commit comments

Comments
 (0)