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:
nhmall
2024-10-08 11:57:46 -04:00
parent 19d8ec6d12
commit a70ad42d22

View File

@@ -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);