@@ -1456,7 +1456,9 @@ pgwin32_doRegister(void)
1456
1456
NULL ,NULL ,"RPCSS\0" ,register_username ,register_password ))== NULL )
1457
1457
{
1458
1458
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 ());
1460
1462
exit (1 );
1461
1463
}
1462
1464
CloseServiceHandle (hService );
@@ -1484,14 +1486,18 @@ pgwin32_doUnregister(void)
1484
1486
if ((hService = OpenService (hSCM ,register_servicename ,DELETE ))== NULL )
1485
1487
{
1486
1488
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 ());
1488
1492
exit (1 );
1489
1493
}
1490
1494
if (!DeleteService (hService ))
1491
1495
{
1492
1496
CloseServiceHandle (hService );
1493
1497
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 ());
1495
1501
exit (1 );
1496
1502
}
1497
1503
CloseServiceHandle (hService );
@@ -1627,7 +1633,9 @@ pgwin32_doRunAsService(void)
1627
1633
1628
1634
if (StartServiceCtrlDispatcher (st )== 0 )
1629
1635
{
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 ());
1631
1639
exit (1 );
1632
1640
}
1633
1641
}
@@ -1708,7 +1716,14 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1708
1716
/* Open the current token to use as a base for the restricted one */
1709
1717
if (!OpenProcessToken (GetCurrentProcess (),TOKEN_ALL_ACCESS ,& origToken ))
1710
1718
{
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 ());
1712
1727
return 0 ;
1713
1728
}
1714
1729
@@ -1721,7 +1736,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1721
1736
SECURITY_BUILTIN_DOMAIN_RID ,DOMAIN_ALIAS_RID_POWER_USERS ,0 ,0 ,0 ,0 ,0 ,
1722
1737
0 ,& dropSids [1 ].Sid ))
1723
1738
{
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 ());
1725
1741
return 0 ;
1726
1742
}
1727
1743
@@ -1740,7 +1756,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1740
1756
1741
1757
if (!b )
1742
1758
{
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 ());
1744
1761
return 0 ;
1745
1762
}
1746
1763
@@ -1791,7 +1808,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1791
1808
HANDLE job ;
1792
1809
char jobname [128 ];
1793
1810
1794
- sprintf (jobname ,"PostgreSQL_%lu" ,processInfo -> dwProcessId );
1811
+ sprintf (jobname ,"PostgreSQL_%lu" ,
1812
+ (unsigned long )processInfo -> dwProcessId );
1795
1813
1796
1814
job = _CreateJobObject (NULL ,jobname );
1797
1815
if (job )