• R/O
  • HTTP
  • SSH
  • HTTPS

MUtilities: 提交

MUtilities development repository


Commit MetaInfo

修订版c027d08c846bd6b9756f6c60ab616a56028f6bcd (tree)
时间2021-12-22 00:20:22
作者LoRd_MuldeR <mulder2@gmx....>
CommiterLoRd_MuldeR

Log Message

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

更改概述

差异

--- a/MUtilities_VS2017.vcxproj
+++ b/MUtilities_VS2017.vcxproj
@@ -162,7 +162,7 @@
162162 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
163163 <ClCompile>
164164 <PrecompiledHeader>NotUsing</PrecompiledHeader>
165- <WarningLevel>Level3</WarningLevel>
165+ <WarningLevel>Level4</WarningLevel>
166166 <Optimization>Disabled</Optimization>
167167 <PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
168168 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -172,6 +172,7 @@
172172 <InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
173173 <BasicRuntimeChecks>Default</BasicRuntimeChecks>
174174 <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
175+ <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
175176 </ClCompile>
176177 <Link>
177178 <SubSystem>Windows</SubSystem>
@@ -182,7 +183,7 @@
182183 </ItemDefinitionGroup>
183184 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
184185 <ClCompile>
185- <WarningLevel>Level3</WarningLevel>
186+ <WarningLevel>Level4</WarningLevel>
186187 <PrecompiledHeader>NotUsing</PrecompiledHeader>
187188 <Optimization>Full</Optimization>
188189 <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -202,6 +203,7 @@
202203 <MinimalRebuild>false</MinimalRebuild>
203204 <ControlFlowGuard>false</ControlFlowGuard>
204205 <WholeProgramOptimization>true</WholeProgramOptimization>
206+ <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
205207 </ClCompile>
206208 <Link>
207209 <SubSystem>Windows</SubSystem>
@@ -215,7 +217,7 @@
215217 </ItemDefinitionGroup>
216218 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
217219 <ClCompile>
218- <WarningLevel>Level3</WarningLevel>
220+ <WarningLevel>Level4</WarningLevel>
219221 <PrecompiledHeader>NotUsing</PrecompiledHeader>
220222 <Optimization>Full</Optimization>
221223 <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -235,6 +237,7 @@
235237 <MinimalRebuild>false</MinimalRebuild>
236238 <ControlFlowGuard>false</ControlFlowGuard>
237239 <WholeProgramOptimization>true</WholeProgramOptimization>
240+ <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
238241 </ClCompile>
239242 <Link>
240243 <SubSystem>Windows</SubSystem>
--- a/MUtilities_VS2019.vcxproj
+++ b/MUtilities_VS2019.vcxproj
@@ -159,7 +159,7 @@
159159 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
160160 <ClCompile>
161161 <PrecompiledHeader>NotUsing</PrecompiledHeader>
162- <WarningLevel>Level3</WarningLevel>
162+ <WarningLevel>Level4</WarningLevel>
163163 <Optimization>Disabled</Optimization>
164164 <PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
165165 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -179,7 +179,7 @@
179179 </ItemDefinitionGroup>
180180 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
181181 <ClCompile>
182- <WarningLevel>Level3</WarningLevel>
182+ <WarningLevel>Level4</WarningLevel>
183183 <PrecompiledHeader>NotUsing</PrecompiledHeader>
184184 <Optimization>Full</Optimization>
185185 <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -212,7 +212,7 @@
212212 </ItemDefinitionGroup>
213213 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
214214 <ClCompile>
215- <WarningLevel>Level3</WarningLevel>
215+ <WarningLevel>Level4</WarningLevel>
216216 <PrecompiledHeader>NotUsing</PrecompiledHeader>
217217 <Optimization>Full</Optimization>
218218 <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -232,6 +232,7 @@
232232 <MinimalRebuild>false</MinimalRebuild>
233233 <ControlFlowGuard>false</ControlFlowGuard>
234234 <WholeProgramOptimization>true</WholeProgramOptimization>
235+ <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
235236 </ClCompile>
236237 <Link>
237238 <SubSystem>Windows</SubSystem>
--- a/MUtilities_VS2022.vcxproj
+++ b/MUtilities_VS2022.vcxproj
@@ -159,7 +159,7 @@
159159 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
160160 <ClCompile>
161161 <PrecompiledHeader>NotUsing</PrecompiledHeader>
162- <WarningLevel>Level3</WarningLevel>
162+ <WarningLevel>Level4</WarningLevel>
163163 <Optimization>Disabled</Optimization>
164164 <PreprocessorDefinitions>WIN32;MUTILS_DLL_EXPORT;_DEBUG;_LIB;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_DLL;QT_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
165165 <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -179,7 +179,7 @@
179179 </ItemDefinitionGroup>
180180 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
181181 <ClCompile>
182- <WarningLevel>Level3</WarningLevel>
182+ <WarningLevel>Level4</WarningLevel>
183183 <PrecompiledHeader>NotUsing</PrecompiledHeader>
184184 <Optimization>Full</Optimization>
185185 <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -212,7 +212,7 @@
212212 </ItemDefinitionGroup>
213213 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_Static|Win32'">
214214 <ClCompile>
215- <WarningLevel>Level3</WarningLevel>
215+ <WarningLevel>Level4</WarningLevel>
216216 <PrecompiledHeader>NotUsing</PrecompiledHeader>
217217 <Optimization>Full</Optimization>
218218 <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -232,6 +232,7 @@
232232 <MinimalRebuild>false</MinimalRebuild>
233233 <ControlFlowGuard>false</ControlFlowGuard>
234234 <WholeProgramOptimization>true</WholeProgramOptimization>
235+ <DisableSpecificWarnings>4714;4324;4127</DisableSpecificWarnings>
235236 </ClCompile>
236237 <Link>
237238 <SubSystem>Windows</SubSystem>
--- a/include/MUtils/Hash.h
+++ b/include/MUtils/Hash.h
@@ -106,7 +106,7 @@ namespace MUtils
106106 QByteArray digest(const bool bAsHex = true) { return bAsHex ? finalize().toHex() : finalize(); }
107107
108108 protected:
109- Hash(const char* key = NULL) {/*nothing to do*/};
109+ Hash(const char* /*key*/ = NULL) {/*nothing to do*/};
110110 virtual bool process(const quint8 *const data, const quint32 len) = 0;
111111 virtual QByteArray finalize(void) = 0;
112112
--- a/include/MUtils/IPCChannel.h
+++ b/include/MUtils/IPCChannel.h
@@ -56,7 +56,7 @@ namespace MUtils
5656 bool read(quint32 &command, quint32 &flags, QStringList &params);
5757
5858 private:
59- IPCChannel(const IPCChannel&) : p(NULL), m_appVersionNo(-1) { throw "Constructor is disabled!"; }
59+ IPCChannel(const IPCChannel&) : p(NULL), m_appVersionNo((unsigned int)(-1)) { throw "Constructor is disabled!"; }
6060 IPCChannel &operator=(const IPCChannel&) { throw "Assignment operator is disabled!"; return *this; }
6161
6262 const QString m_applicationId;
--- a/src/3rd_party/strnatcmp/src/strnatcmp.cpp
+++ b/src/3rd_party/strnatcmp/src/strnatcmp.cpp
@@ -97,10 +97,10 @@ static int compare_right(nat_char const *a, nat_char const *b)
9797 return bias;
9898 }
9999
100- return 0;
100+ // return 0;
101101 }
102102
103-static int compare_left(nat_char const *a,nat_char const *b)
103+static int compare_left(nat_char const *a, nat_char const *b)
104104 {
105105 /* Compare two left-aligned numbers: the first to have a
106106 different value wins. */
@@ -118,7 +118,7 @@ static int compare_left(nat_char const *a,nat_char const *b)
118118 return +1;
119119 }
120120
121- return 0;
121+ // return 0;
122122 }
123123
124124 static int strnatcmp0(nat_char const *a, nat_char const *b, const bool fold_case)
--- a/src/ErrorHandler_Win32.cpp
+++ b/src/ErrorHandler_Win32.cpp
@@ -35,7 +35,7 @@
3535 ///////////////////////////////////////////////////////////////////////////////
3636
3737 // Invalid parameters handler
38-static void my_invalid_param_handler(const wchar_t* exp, const wchar_t* fun, const wchar_t* fil, unsigned int, uintptr_t)
38+static void my_invalid_param_handler(const wchar_t* /*exp*/, const wchar_t* /*fun*/, const wchar_t* /*fil*/, unsigned int, uintptr_t)
3939 {
4040 MUtils::OS::fatal_exit(L"Invalid parameter handler invoked, application will exit!");
4141 }
@@ -48,7 +48,7 @@ static void my_signal_handler(int signal_num)
4848 }
4949
5050 // Global exception handler
51-static LONG WINAPI my_exception_handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
51+static LONG WINAPI my_exception_handler(struct _EXCEPTION_POINTERS* /*ExceptionInfo*/)
5252 {
5353 MUtils::OS::fatal_exit(L"Unhandeled exception handler invoked, application will exit!");
5454 return LONG_MAX;
--- a/src/Global.cpp
+++ b/src/Global.cpp
@@ -247,7 +247,7 @@ QString MUtils::make_temp_file(const QDir &basePath, const QString &extension, c
247247
248248 QString MUtils::make_unique_file(const QString &basePath, const QString &baseName, const QString &extension, const bool fancy, const bool placeholder)
249249 {
250- return make_unique_file(QDir(basePath), baseName, extension, fancy);
250+ return make_unique_file(QDir(basePath), baseName, extension, fancy, placeholder);
251251 }
252252
253253 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,
282282
283283 if (placeholder && (!fileName.isEmpty()))
284284 {
285- QFile placeholder(fileName);
286- if (placeholder.open(QIODevice::WriteOnly))
285+ QFile placeholderFile(fileName);
286+ if (placeholderFile.open(QIODevice::WriteOnly))
287287 {
288- placeholder.close();
288+ placeholderFile.close();
289289 }
290290 }
291291
--- a/src/OSSupport_Win32.cpp
+++ b/src/OSSupport_Win32.cpp
@@ -180,7 +180,7 @@ typedef struct _progress_callback_data_t
180180 }
181181 progress_callback_data_t;
182182
183-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)
183+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)
184184 {
185185 if(const progress_callback_data_t *data = (progress_callback_data_t*) lpData)
186186 {
@@ -1439,7 +1439,7 @@ bool MUtils::OS::free_diskspace(const QString &path, quint64 &freeSpace)
14391439 return true;;
14401440 }
14411441
1442- freeSpace = -1;
1442+ freeSpace = static_cast<quint64>(-1);
14431443 return false;
14441444 }
14451445
@@ -2012,7 +2012,7 @@ static volatile bool g_debug_check = check_debugger_helper();
20122012 static MUtils::Internal::CriticalSection g_fatal_exit_lock;
20132013 static QAtomicInt g_fatal_exit_flag;
20142014
2015-static BOOL CALLBACK fatal_exit_enum_helper(const HWND hwnd, const LPARAM lParam)
2015+static BOOL CALLBACK fatal_exit_enum_helper(const HWND hwnd, const LPARAM /*lParam*/)
20162016 {
20172017 SetWindowPos(hwnd, HWND_NOTOPMOST, NULL, NULL, NULL, NULL, SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE);
20182018 return TRUE;
--- a/src/Registry_Win32.cpp
+++ b/src/Registry_Win32.cpp
@@ -191,7 +191,7 @@ bool MUtils::Registry::RegistryKey::value_write(const QString &valueName, const
191191 bool MUtils::Registry::RegistryKey::value_read(const QString &valueName, quint32 &value) const
192192 {
193193 value = 0;
194- DWORD size = sizeof(quint32), type = -1;
194+ DWORD size = sizeof(quint32), type = static_cast<DWORD>(-1);
195195 CHECK_STATUS(KEY_READ);
196196 return (RegQueryValueEx(p->m_hKey, valueName.isEmpty() ? NULL : MUTILS_WCHR(valueName), 0, &type, reinterpret_cast<BYTE*>(&value), &size) == ERROR_SUCCESS) && (type == REG_DWORD);
197197 }
@@ -199,7 +199,7 @@ bool MUtils::Registry::RegistryKey::value_read(const QString &valueName, quint32
199199 bool MUtils::Registry::RegistryKey::value_read(const QString &valueName, QString &value) const
200200 {
201201 value = QString();
202- wchar_t buffer[2048]; DWORD size = sizeof(wchar_t) * 2048, type = -1;
202+ wchar_t buffer[2048]; DWORD size = sizeof(wchar_t) * 2048, type = static_cast<DWORD>(-1);
203203 CHECK_STATUS(KEY_READ);
204204 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)))
205205 {
--- a/src/Sound_Win32.cpp
+++ b/src/Sound_Win32.cpp
@@ -103,7 +103,7 @@ bool MUtils::Sound::play_sound(const QString &name, const bool &bAsync)
103103 {
104104 if(const unsigned char *data = get_sound_from_cache(name))
105105 {
106- return PlaySound(LPCWSTR(data), NULL, (SND_MEMORY | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
106+ return PlaySoundW(LPCWSTR(data), NULL, (SND_MEMORY | (bAsync ? SND_ASYNC : SND_SYNC)));
107107 }
108108 }
109109
@@ -112,7 +112,12 @@ bool MUtils::Sound::play_sound(const QString &name, const bool &bAsync)
112112
113113 bool MUtils::Sound::play_system_sound(const QString &alias, const bool &bAsync)
114114 {
115- return PlaySound(MUTILS_WCHR(alias), GetModuleHandle(NULL), (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE;
115+ if (!alias.isEmpty())
116+ {
117+ return PlaySoundW(MUTILS_WCHR(alias), NULL, (SND_ALIAS | (bAsync ? SND_ASYNC : SND_SYNC)));
118+ }
119+
120+ return false;
116121 }
117122
118123 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
131136
132137 if(libraryFile.exists() && libraryFile.isFile())
133138 {
134- if(const HMODULE module = GetModuleHandleW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
139+ if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
135140 {
136- result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
141+ result = PlaySoundW(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC)));
142+ FreeLibrary(module);
137143 }
138- else if(const HMODULE module = LoadLibraryW(MUTILS_WCHR(QDir::toNativeSeparators(libraryFile.canonicalFilePath()))))
144+ else
139145 {
140- result = (PlaySound(MAKEINTRESOURCE(uiSoundIdx), module, (SND_RESOURCE | (bAsync ? SND_ASYNC : SND_SYNC))) != FALSE);
141- FreeLibrary(module);
146+ qWarning("PlaySound: File \"%s\" failed to load!", MUTILS_UTF8(libraryFile.absoluteFilePath()));
142147 }
143148 }
144149 else
--- a/src/Terminal_Win32.cpp
+++ b/src/Terminal_Win32.cpp
@@ -203,7 +203,7 @@ void MUtils::Terminal::setup(int &argc, char **argv, const char* const appName,
203203 g_terminal_log_file.reset(new QFile(MUTILS_QSTR(logfile)));
204204 if(g_terminal_log_file->open(QIODevice::WriteOnly))
205205 {
206- static const char MARKER[3] = { char(0xEF), char(0xBB), char(0xBF) };
206+ static const char MARKER[3] = { '\xEF', '\xBB', '\xBF' };
207207 g_terminal_log_file->write(MARKER, 3);
208208 }
209209 free(logfile);
--- a/src/Translation.cpp
+++ b/src/Translation.cpp
@@ -106,7 +106,7 @@ int MUtils::Translation::enumerate(QStringList &list)
106106 return -1;
107107 }
108108
109- list.swap(g_translation_data->keys());
109+ list = g_translation_data->keys();
110110 return list.count();
111111 }
112112
Show on old repository browser