Skip to content

Commit

Permalink
QtCore/QtNetwork/QTestlib: Fix build with MinGW/g++ 8.1 x64
Browse files Browse the repository at this point in the history
Fix warnings about invalid function type casts (return types
conflicting with the FARPROC returned by GetProcAddress()) like:
corelib\global\qoperatingsystemversion_win.cpp:100:48: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'RtlGetVersionFunction' {aka 'long int (*)(_OSVERSIONINFOW*)'} [-Werror=cast-function-type]
io\qlockfile_win.cpp:158:85: error: cast between incompatible function types from 'FARPROC' {aka 'long long int (*)()'} to 'GetModuleFileNameExFunc' {aka 'long unsigned int (*)(void*, HINSTANCE__*, wchar_t*, long unsigned int)'} [-Werror=cast-function-type]

by introducing nested casts.

Task-number: QTBUG-68742
Task-number: QTQAINFRA-2095
Change-Id: I3a5d2ea901bf5dc35963c589d61cf3dc7393377a
Reviewed-by: Timur Pocheptsov <[email protected]>
  • Loading branch information
FriedemannKleint committed Jun 25, 2018
1 parent 7c34e0a commit e21d1d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/corelib/global/qoperatingsystemversion_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
// because linking to it at load time will not pass the Windows App Certification Kit
// https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910.aspx
RtlGetVersionFunction pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>(
GetProcAddressA(ntdll, "RtlGetVersion"));
reinterpret_cast<QFunctionPointer>(GetProcAddressA(ntdll, "RtlGetVersion")));
if (Q_UNLIKELY(!pRtlGetVersion))
return result;

Expand Down
5 changes: 2 additions & 3 deletions src/corelib/io/qlockfile_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
HMODULE hPsapi = LoadLibraryA("psapi");
if (!hPsapi)
return QString();

GetModuleFileNameExFunc qGetModuleFileNameEx
= (GetModuleFileNameExFunc)GetProcAddress(hPsapi, "GetModuleFileNameExW");
GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
reinterpret_cast<QFunctionPointer>(GetProcAddress(hPsapi, "GetModuleFileNameExW")));
if (!qGetModuleFileNameEx) {
FreeLibrary(hPsapi);
return QString();
Expand Down
4 changes: 2 additions & 2 deletions src/network/kernel/qauthenticator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1454,8 +1454,8 @@ static bool q_NTLM_SSPI_library_load()
securityDLLHandle = LoadLibrary(L"secur32.dll");
if (securityDLLHandle != NULL) {
INIT_SECURITY_INTERFACE pInitSecurityInterface =
(INIT_SECURITY_INTERFACE)GetProcAddress(securityDLLHandle,
"InitSecurityInterfaceW");
reinterpret_cast<INIT_SECURITY_INTERFACE>(
reinterpret_cast<QFunctionPointer>(GetProcAddress(securityDLLHandle, "InitSecurityInterfaceW")));
if (pInitSecurityInterface != NULL)
pSecurityFunctionTable = pInitSecurityInterface();
}
Expand Down
6 changes: 4 additions & 2 deletions src/testlib/qtestcase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1603,8 +1603,10 @@ DebugSymbolResolver::DebugSymbolResolver(HANDLE process)
bool success = false;
m_dbgHelpLib = LoadLibraryW(L"dbghelp.dll");
if (m_dbgHelpLib) {
SymInitializeType symInitialize = (SymInitializeType)(GetProcAddress(m_dbgHelpLib, "SymInitialize"));
m_symFromAddr = (SymFromAddrType)(GetProcAddress(m_dbgHelpLib, "SymFromAddr"));
SymInitializeType symInitialize = reinterpret_cast<SymInitializeType>(
reinterpret_cast<QFunctionPointer>(GetProcAddress(m_dbgHelpLib, "SymInitialize")));
m_symFromAddr = reinterpret_cast<SymFromAddrType>(
reinterpret_cast<QFunctionPointer>(GetProcAddress(m_dbgHelpLib, "SymFromAddr")));
success = symInitialize && m_symFromAddr && symInitialize(process, NULL, TRUE);
}
if (!success)
Expand Down

0 comments on commit e21d1d3

Please sign in to comment.