address Windows windsys.c analyzer complaints
sys/windows/windsys.c(419): warning C6387: 'hMod' could be '0':
this does not adhere to the specification for the function 'GetProcAddress'.
sys/windows/windsys.c(437): warning C28159:
Consider using 'GetTickCount64' instead of 'GetTickCount'.
Reason: GetTickCount overflows roughly every 49 days. Code that does not
take that into account can loop indefinitely.
GetTickCount64 operates on 64 bit values and does not have that
problem
This commit is contained in:
@@ -416,12 +416,14 @@ static HWND
|
||||
GetConsoleHandle(void)
|
||||
{
|
||||
HMODULE hMod = GetModuleHandle("kernel32.dll");
|
||||
GETCONSOLEWINDOW pfnGetConsoleWindow =
|
||||
(GETCONSOLEWINDOW) GetProcAddress(hMod, "GetConsoleWindow");
|
||||
if (pfnGetConsoleWindow)
|
||||
return pfnGetConsoleWindow();
|
||||
else
|
||||
return GetConsoleHwnd();
|
||||
|
||||
if (hMod) {
|
||||
GETCONSOLEWINDOW pfnGetConsoleWindow =
|
||||
(GETCONSOLEWINDOW) GetProcAddress(hMod, "GetConsoleWindow");
|
||||
if (pfnGetConsoleWindow)
|
||||
return pfnGetConsoleWindow();
|
||||
}
|
||||
return GetConsoleHwnd();
|
||||
}
|
||||
|
||||
static HWND
|
||||
@@ -434,7 +436,7 @@ GetConsoleHwnd(void)
|
||||
/* Get current window title */
|
||||
GetConsoleTitle(OldTitle, sizeof OldTitle);
|
||||
|
||||
(void) sprintf(NewTitle, "NETHACK%ld/%ld", GetTickCount(),
|
||||
(void) sprintf(NewTitle, "NETHACK%lld/%ld", GetTickCount64(),
|
||||
GetCurrentProcessId());
|
||||
SetConsoleTitle(NewTitle);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user