OSDN Git Service

Increased warning level to #4 and fixed a number of warnings.
authorLoRd_MuldeR <mulder2@gmx.de>
Tue, 21 Dec 2021 15:20:22 +0000 (16:20 +0100)
committerLoRd_MuldeR <mulder2@gmx.de>
Tue, 21 Dec 2021 15:20:22 +0000 (16:20 +0100)
13 files changed:
MUtilities_VS2017.vcxproj
MUtilities_VS2019.vcxproj
MUtilities_VS2022.vcxproj
include/MUtils/Hash.h
include/MUtils/IPCChannel.h
src/3rd_party/strnatcmp/src/strnatcmp.cpp
src/ErrorHandler_Win32.cpp
src/Global.cpp
src/OSSupport_Win32.cpp
src/Registry_Win32.cpp
src/Sound_Win32.cpp
src/Terminal_Win32.cpp
src/Translation.cpp

index edad498..f58dba7 100644 (file)
   <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>
       <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
       <BasicRuntimeChecks>Default</BasicRuntimeChecks>
       <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <MinimalRebuild>false</MinimalRebuild>
       <ControlFlowGuard>false</ControlFlowGuard>
       <WholeProgramOptimization>true</WholeProgramOptimization>
+      <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
     <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <MinimalRebuild>false</MinimalRebuild>
       <ControlFlowGuard>false</ControlFlowGuard>
       <WholeProgramOptimization>true</WholeProgramOptimization>
+      <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
index 0777dc9..a2e192e 100644 (file)
   <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>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
     <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <MinimalRebuild>false</MinimalRebuild>
       <ControlFlowGuard>false</ControlFlowGuard>
       <WholeProgramOptimization>true</WholeProgramOptimization>
+      <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
index 54123c6..207c499 100644 (file)
   <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>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
     <ClCompile>
-      <WarningLevel>Level3</WarningLevel>
+      <WarningLevel>Level4</WarningLevel>
       <PrecompiledHeader>NotUsing</PrecompiledHeader>
       <Optimization>Full</Optimization>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <MinimalRebuild>false</MinimalRebuild>
       <ControlFlowGuard>false</ControlFlowGuard>
       <WholeProgramOptimization>true</WholeProgramOptimization>
+      <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
index ea0288c..2217f72 100644 (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;
 
index cbcdf26..580ee75 100644 (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;
index 813a69f..74a2944 100644 (file)
@@ -97,10 +97,10 @@ 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)
+static int compare_left(nat_char const *a, nat_char const *b)
 {
        /* Compare two left-aligned numbers: the first to have a
        different value wins. */
@@ -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)
index 048fa48..ea973d7 100644 (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;
index 54e4816..7a93a74 100644 (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();
                }
        }
 
index df60224..8351641 100644 (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;
index 323d609..9dd6471 100644 (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)))
        {
index 34ca5f9..ab54d2e 100644 (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,14 +136,14 @@ 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);
+                       result = PlaySoundW(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC)));
+                       FreeLibrary(module);
                }
-               else if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
+               else
                {
-                       result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
-                       FreeLibrary(module);
+                       qWarning("PlaySound: File \"%s\" failed to load!", MUTILS_UTF8(libraryFile.absoluteFilePath()));
                }
        }
        else
index cd6d698..bdc5e60 100644 (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);
index 5bd41b1..c15b46a 100644 (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();
 }