Increased warning level to #4 and fixed a number of warnings.

This commit is contained in:
LoRd_MuldeR 2021-12-21 16:20:22 +01:00
parent b9ce1421dd
commit c027d08c84
13 changed files with 45 additions and 35 deletions

View File

@ -162,7 +162,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -172,6 +172,7 @@
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -182,7 +183,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -202,6 +203,7 @@
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -215,7 +217,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -235,6 +237,7 @@
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -159,7 +159,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -179,7 +179,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -212,7 +212,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -232,6 +232,7 @@
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -159,7 +159,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@ -179,7 +179,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -212,7 +212,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<WarningLevel>Level4</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
@ -232,6 +232,7 @@
<MinimalRebuild>false</MinimalRebuild>
<ControlFlowGuard>false</ControlFlowGuard>
<WholeProgramOptimization>true</WholeProgramOptimization>
<DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -106,7 +106,7 @@ namespace MUtils
QByteArray digest(const bool bAsHex = true) { return bAsHex ? finalize().toHex() : finalize(); }
protected:
Hash(const char* key = NULL) {/*nothing to do*/};
Hash(const char* /*key*/ = NULL) {/*nothing to do*/};
virtual bool process(const quint8 *const data, const quint32 len) = 0;
virtual QByteArray finalize(void) = 0;

View File

@ -56,7 +56,7 @@ namespace MUtils
bool read(quint32 &command, quint32 &flags, QStringList &params);
private:
IPCChannel(const IPCChannel&) : p(NULL), m_appVersionNo(-1) { throw "Constructor is disabled!"; }
IPCChannel(const IPCChannel&) : p(NULL), m_appVersionNo((unsigned int)(-1)) { throw "Constructor is disabled!"; }
IPCChannel &operator=(const IPCChannel&) { throw "Assignment operator is disabled!"; return *this; }
const QString m_applicationId;

View File

@ -97,7 +97,7 @@ static int compare_right(nat_char const *a, nat_char const *b)
return bias;
}
return 0;
// return 0;
}
static int compare_left(nat_char const *a, nat_char const *b)
@ -118,7 +118,7 @@ static int compare_left(nat_char const *a,nat_char const *b)
return +1;
}
return 0;
// return 0;
}
static int strnatcmp0(nat_char const *a, nat_char const *b, const bool fold_case)

View File

@ -35,7 +35,7 @@
///////////////////////////////////////////////////////////////////////////////
// Invalid parameters handler
static void my_invalid_param_handler(const wchar_t* exp, const wchar_t* fun, const wchar_t* fil, unsigned int, uintptr_t)
static void my_invalid_param_handler(const wchar_t* /*exp*/, const wchar_t* /*fun*/, const wchar_t* /*fil*/, unsigned int, uintptr_t)
{
MUtils::OS::fatal_exit(L"Invalid parameter handler invoked, application will exit!");
}
@ -48,7 +48,7 @@ static void my_signal_handler(int signal_num)
}
// Global exception handler
static LONG WINAPI my_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
static LONG WINAPI my_exception_handler(struct _EXCEPTION_POINTERS* /*ExceptionInfo*/)
{
MUtils::OS::fatal_exit(L"Unhandeled exception handler invoked, application will exit!");
return LONG_MAX;

View File

@ -247,7 +247,7 @@ QString MUtils::make_temp_file(const QDir &basePath, const QString &extension, c
QString MUtils::make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy, const bool placeholder)
{
return make_unique_file(QDir(basePath), baseName, extension, fancy);
return make_unique_file(QDir(basePath), baseName, extension, fancy, placeholder);
}
QString MUtils::make_unique_file(const QDir &basePath, const QString &baseName, const QString &extension, const bool fancy, const bool placeholder)
@ -282,10 +282,10 @@ QString MUtils::make_unique_file(const QDir &basePath, const QString &baseName,
if (placeholder && (!fileName.isEmpty()))
{
QFile placeholder(fileName);
if (placeholder.open(QIODevice::WriteOnly))
QFile placeholderFile(fileName);
if (placeholderFile.open(QIODevice::WriteOnly))
{
placeholder.close();
placeholderFile.close();
}
}

View File

@ -180,7 +180,7 @@ typedef struct _progress_callback_data_t
}
progress_callback_data_t;
static DWORD __stdcall copy_file_progress(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER StreamSize, LARGE_INTEGER StreamBytesTransferred, DWORD dwStreamNumber, DWORD dwCallbackReason, HANDLE hSourceFile, HANDLE hDestinationFile, LPVOID lpData)
static DWORD __stdcall copy_file_progress(LARGE_INTEGER TotalFileSize, LARGE_INTEGER TotalBytesTransferred, LARGE_INTEGER /*StreamSize*/, LARGE_INTEGER /*StreamBytesTransferred*/, DWORD /*dwStreamNumber*/, DWORD /*dwCallbackReason*/, HANDLE /*hSourceFile*/, HANDLE /*hDestinationFile*/, LPVOID lpData)
{
if(const progress_callback_data_t *data = (progress_callback_data_t*) lpData)
{
@ -1439,7 +1439,7 @@ bool MUtils::OS::free_diskspace(const QString &path, quint64 &freeSpace)
return true;;
}
freeSpace = -1;
freeSpace = static_cast<quint64>(-1);
return false;
}
@ -2012,7 +2012,7 @@ static volatile bool g_debug_check = check_debugger_helper();
static MUtils::Internal::CriticalSection g_fatal_exit_lock;
static QAtomicInt g_fatal_exit_flag;
static BOOL CALLBACK fatal_exit_enum_helper(const HWND hwnd, const LPARAM lParam)
static BOOL CALLBACK fatal_exit_enum_helper(const HWND hwnd, const LPARAM /*lParam*/)
{
SetWindowPos(hwnd, HWND_NOTOPMOST, NULL, NULL, NULL, NULL, SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE);
return TRUE;

View File

@ -191,7 +191,7 @@ bool MUtils::Registry::RegistryKey::value_write(const QString &valueName, const
bool MUtils::Registry::RegistryKey::value_read(const QString &valueName, quint32 &value) const
{
value = 0;
DWORD size = sizeof(quint32), type = -1;
DWORD size = sizeof(quint32), type = static_cast<DWORD>(-1);
CHECK_STATUS(KEY_READ);
return (RegQueryValueEx(p->m_hKey, valueName.isEmpty() ? NULL : MUTILS_WCHR(valueName), 0, &type, reinterpret_cast<BYTE*>(&value), &size) == ERROR_SUCCESS) && (type == REG_DWORD);
}
@ -199,7 +199,7 @@ bool MUtils::Registry::RegistryKey::value_read(const QString &valueName, quint32
bool MUtils::Registry::RegistryKey::value_read(const QString &valueName, QString &value) const
{
value = QString();
wchar_t buffer[2048]; DWORD size = sizeof(wchar_t) * 2048, type = -1;
wchar_t buffer[2048]; DWORD size = sizeof(wchar_t) * 2048, type = static_cast<DWORD>(-1);
CHECK_STATUS(KEY_READ);
if((RegQueryValueEx(p->m_hKey, valueName.isEmpty() ? NULL : MUTILS_WCHR(valueName), 0, &type, reinterpret_cast<BYTE*>(&(buffer[0])), &size) == ERROR_SUCCESS) && ((type == REG_SZ) || (type == REG_EXPAND_SZ)))
{

View File

@ -103,7 +103,7 @@ bool MUtils::Sound::play_sound(const QString &name, const bool &bAsync)
{
if(const unsigned char *data = get_sound_from_cache(name))
{
return PlaySound(LPCWSTR(data), NULL, (SND_MEMORY | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
return PlaySoundW(LPCWSTR(data), NULL, (SND_MEMORY | (bAsync ? SND_ASYNC : SND_SYNC)));
}
}
@ -112,7 +112,12 @@ bool MUtils::Sound::play_sound(const QString &name, const bool &bAsync)
bool MUtils::Sound::play_system_sound(const QString &alias, const bool &bAsync)
{
return PlaySound(MUTILS_WCHR(alias), GetModuleHandle(NULL), (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
if (!alias.isEmpty())
{
return PlaySoundW(MUTILS_WCHR(alias), NULL, (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC)));
}
return false;
}
bool MUtils::Sound::play_sound_file(const QString &library, const unsigned short uiSoundIdx, const bool &bAsync)
@ -131,15 +136,15 @@ bool MUtils::Sound::play_sound_file(const QString &library, const unsigned short
if(libraryFile.exists() && libraryFile.isFile())
{
if(const HMODULE module = GetModuleHandleW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
{
result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
}
else if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
{
result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
result = PlaySoundW(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC)));
FreeLibrary(module);
}
else
{
qWarning("PlaySound: File \"%s\" failed to load!", MUTILS_UTF8(libraryFile.absoluteFilePath()));
}
}
else
{

View File

@ -203,7 +203,7 @@ void MUtils::Terminal::setup(int &argc, char **argv, const char* const appName,
g_terminal_log_file.reset(new QFile(MUTILS_QSTR(logfile)));
if(g_terminal_log_file->open(QIODevice::WriteOnly))
{
static const char MARKER[3] = { char(0xEF), char(0xBB), char(0xBF) };
static const char MARKER[3] = { '\xEF', '\xBB', '\xBF' };
g_terminal_log_file->write(MARKER, 3);
}
free(logfile);

View File

@ -106,7 +106,7 @@ int MUtils::Translation::enumerate(QStringList &list)
return -1;
}
list.swap(g_translation_data->keys());
list = g_translation_data->keys();
return list.count();
}