mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Use consistent format for reporting GetLastError()
Use something like "error code %lu" for reporting GetLastError() values on Windows. Previously, a mix of different wordings and formats were in use.
This commit is contained in:
@@ -144,8 +144,8 @@ crashDumpHandler(struct _EXCEPTION_POINTERS * pExceptionInfo)
|
||||
NULL);
|
||||
if (dumpFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
write_stderr("could not open crash dump file \"%s\" for writing: error code %u\n",
|
||||
dumpPath, (unsigned int) GetLastError());
|
||||
write_stderr("could not open crash dump file \"%s\" for writing: error code %lu\n",
|
||||
dumpPath, GetLastError());
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
@@ -153,8 +153,8 @@ crashDumpHandler(struct _EXCEPTION_POINTERS * pExceptionInfo)
|
||||
NULL, NULL))
|
||||
write_stderr("wrote crash dump to file \"%s\"\n", dumpPath);
|
||||
else
|
||||
write_stderr("could not write crash dump to file \"%s\": error code %08x\n",
|
||||
dumpPath, (unsigned int) GetLastError());
|
||||
write_stderr("could not write crash dump to file \"%s\": error code %lu\n",
|
||||
dumpPath, GetLastError());
|
||||
|
||||
CloseHandle(dumpFile);
|
||||
}
|
||||
|
@@ -42,8 +42,8 @@ LoadKernel32()
|
||||
kernel32 = LoadLibraryEx("kernel32.dll", NULL, 0);
|
||||
if (kernel32 == NULL)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("could not load kernel32.dll: %d",
|
||||
(int) GetLastError())));
|
||||
(errmsg_internal("could not load kernel32.dll: error code %lu",
|
||||
GetLastError())));
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ RegisterWaitForSingleObject(PHANDLE phNewWaitObject,
|
||||
|
||||
if (_RegisterWaitForSingleObject == NULL)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("could not locate RegisterWaitForSingleObject in kernel32.dll: %d",
|
||||
(int) GetLastError())));
|
||||
(errmsg_internal("could not locate RegisterWaitForSingleObject in kernel32.dll: error code %lu",
|
||||
GetLastError())));
|
||||
}
|
||||
|
||||
return (_RegisterWaitForSingleObject)
|
||||
|
@@ -40,8 +40,8 @@ pgwin32_is_admin(void)
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &AccessToken))
|
||||
{
|
||||
write_stderr("could not open process token: error code %d\n",
|
||||
(int) GetLastError());
|
||||
write_stderr("could not open process token: error code %lu\n",
|
||||
GetLastError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ pgwin32_is_admin(void)
|
||||
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
|
||||
0, &AdministratorsSid))
|
||||
{
|
||||
write_stderr("could not get SID for Administrators group: error code %d\n",
|
||||
(int) GetLastError());
|
||||
write_stderr("could not get SID for Administrators group: error code %lu\n",
|
||||
GetLastError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ pgwin32_is_admin(void)
|
||||
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
|
||||
0, &PowerUsersSid))
|
||||
{
|
||||
write_stderr("could not get SID for PowerUsers group: error code %d\n",
|
||||
(int) GetLastError());
|
||||
write_stderr("could not get SID for PowerUsers group: error code %lu\n",
|
||||
GetLastError());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ pgwin32_is_service(void)
|
||||
|
||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &AccessToken))
|
||||
{
|
||||
fprintf(stderr, "could not open process token: error code %d\n",
|
||||
(int) GetLastError());
|
||||
fprintf(stderr, "could not open process token: error code %lu\n",
|
||||
GetLastError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -223,8 +223,8 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class,
|
||||
|
||||
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
snprintf(errbuf, errsize, "could not get token information: error code %d\n",
|
||||
(int) GetLastError());
|
||||
snprintf(errbuf, errsize, "could not get token information: error code %lu\n",
|
||||
GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -239,8 +239,8 @@ pgwin32_get_dynamic_tokeninfo(HANDLE token, TOKEN_INFORMATION_CLASS class,
|
||||
if (!GetTokenInformation(token, class, *InfoBuffer,
|
||||
InfoBufferSize, &InfoBufferSize))
|
||||
{
|
||||
snprintf(errbuf, errsize, "could not get token information: error code %d\n",
|
||||
(int) GetLastError());
|
||||
snprintf(errbuf, errsize, "could not get token information: error code %lu\n",
|
||||
GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ pgwin32_signal_initialize(void)
|
||||
pgwin32_signal_event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (pgwin32_signal_event == NULL)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("could not create signal event: %d", (int) GetLastError())));
|
||||
(errmsg_internal("could not create signal event: error code %lu", GetLastError())));
|
||||
|
||||
/* Create thread for handling signals */
|
||||
signal_thread_handle = CreateThread(NULL, 0, pg_signal_thread, NULL, 0, NULL);
|
||||
@@ -186,8 +186,8 @@ pgwin32_create_signal_listener(pid_t pid)
|
||||
|
||||
if (pipe == INVALID_HANDLE_VALUE)
|
||||
ereport(ERROR,
|
||||
(errmsg("could not create signal listener pipe for PID %d: error code %d",
|
||||
(int) pid, (int) GetLastError())));
|
||||
(errmsg("could not create signal listener pipe for PID %d: error code %lu",
|
||||
(int) pid, GetLastError())));
|
||||
|
||||
return pipe;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ pg_signal_thread(LPVOID param)
|
||||
|
||||
if (pipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
write_stderr("could not create signal listener pipe: error code %d; retrying\n", (int) GetLastError());
|
||||
write_stderr("could not create signal listener pipe: error code %lu; retrying\n", GetLastError());
|
||||
SleepEx(500, FALSE);
|
||||
continue;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ pg_signal_thread(LPVOID param)
|
||||
* is nothing else we can do other than abort the whole
|
||||
* process which will be even worse.
|
||||
*/
|
||||
write_stderr("could not create signal listener pipe: error code %d; retrying\n", (int) GetLastError());
|
||||
write_stderr("could not create signal listener pipe: error code %lu; retrying\n", GetLastError());
|
||||
|
||||
/*
|
||||
* Keep going so we at least dispatch this signal. Hopefully,
|
||||
@@ -309,8 +309,8 @@ pg_signal_thread(LPVOID param)
|
||||
(LPTHREAD_START_ROUTINE) pg_signal_dispatch_thread,
|
||||
(LPVOID) pipe, 0, NULL);
|
||||
if (hThread == INVALID_HANDLE_VALUE)
|
||||
write_stderr("could not create signal dispatch thread: error code %d\n",
|
||||
(int) GetLastError());
|
||||
write_stderr("could not create signal dispatch thread: error code %lu\n",
|
||||
GetLastError());
|
||||
else
|
||||
CloseHandle(hThread);
|
||||
|
||||
|
@@ -143,11 +143,11 @@ pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
|
||||
|
||||
if (waitevent == INVALID_HANDLE_VALUE)
|
||||
ereport(ERROR,
|
||||
(errmsg_internal("could not create socket waiting event: %d", (int) GetLastError())));
|
||||
(errmsg_internal("could not create socket waiting event: error code %lu", GetLastError())));
|
||||
}
|
||||
else if (!ResetEvent(waitevent))
|
||||
ereport(ERROR,
|
||||
(errmsg_internal("could not reset socket waiting event: %d", (int) GetLastError())));
|
||||
(errmsg_internal("could not reset socket waiting event: error code %lu", GetLastError())));
|
||||
|
||||
/*
|
||||
* make sure we don't multiplex this kernel event object with a different
|
||||
@@ -221,7 +221,7 @@ pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
|
||||
if (r == WAIT_TIMEOUT)
|
||||
return 0;
|
||||
ereport(ERROR,
|
||||
(errmsg_internal("unrecognized return value from WaitForMultipleObjects: %d (%d)", r, (int) GetLastError())));
|
||||
(errmsg_internal("unrecognized return value from WaitForMultipleObjects: %d (%lu)", r, GetLastError())));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -567,7 +567,7 @@ pgwin32_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, c
|
||||
ZeroMemory(&resEvents, sizeof(resEvents));
|
||||
if (WSAEnumNetworkEvents(sockets[i], events[i], &resEvents) == SOCKET_ERROR)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("failed to enumerate network events: %d", (int) GetLastError())));
|
||||
(errmsg_internal("failed to enumerate network events: error code %lu", GetLastError())));
|
||||
/* Read activity? */
|
||||
if (readfds && FD_ISSET(sockets[i], readfds))
|
||||
{
|
||||
@@ -645,7 +645,7 @@ pgwin32_socket_strerror(int err)
|
||||
handleDLL = LoadLibraryEx("netmsg.dll", NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (handleDLL == NULL)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("could not load netmsg.dll: %d", (int) GetLastError())));
|
||||
(errmsg_internal("could not load netmsg.dll: error code %lu", GetLastError())));
|
||||
}
|
||||
|
||||
ZeroMemory(&wserrbuf, sizeof(wserrbuf));
|
||||
|
@@ -97,8 +97,8 @@ setitimer(int which, const struct itimerval * value, struct itimerval * ovalue)
|
||||
timerCommArea.event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (timerCommArea.event == NULL)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("could not create timer event: %d",
|
||||
(int) GetLastError())));
|
||||
(errmsg_internal("could not create timer event: error code %lu",
|
||||
GetLastError())));
|
||||
|
||||
MemSet(&timerCommArea.value, 0, sizeof(struct itimerval));
|
||||
|
||||
@@ -107,8 +107,8 @@ setitimer(int which, const struct itimerval * value, struct itimerval * ovalue)
|
||||
timerThreadHandle = CreateThread(NULL, 0, pg_timer_thread, NULL, 0, NULL);
|
||||
if (timerThreadHandle == INVALID_HANDLE_VALUE)
|
||||
ereport(FATAL,
|
||||
(errmsg_internal("could not create timer thread: %d",
|
||||
(int) GetLastError())));
|
||||
(errmsg_internal("could not create timer thread: error code %lu",
|
||||
GetLastError())));
|
||||
}
|
||||
|
||||
/* Request the timer thread to change settings */
|
||||
|
Reference in New Issue
Block a user