etternagame / etterna

Advanced cross-platform rhythm game focused on keyboard play
https://etternaonline.com/
MIT License
497 stars 135 forks source link

Fix most clang warnings on windows #1172

Closed nico-abram closed 1 year ago

nico-abram commented 2 years ago

Ignoring the warnings BlueBandit fixed in https://github.com/etternagame/etterna/pull/1171 , these are the warnings that are left when running clang on windows after this PR:

Remaining warnings [203/655] Building CXX object CMakeFiles\Etterna.dir\src\Etterna\Models\Misc\PlayerInfo.cpp.obj In file included from D:\dev\etterna\src\Etterna\Models\Misc\PlayerInfo.cpp:12: D:\dev\etterna\src\Etterna/Actor/Gameplay/PlayerReplay.h(25,7): warning: 'PlayerReplay::Step' hides overloaded virtual function [-Woverloaded-virtual] void Step(int col, ^ D:\dev\etterna\src\Etterna/Actor/Gameplay/Player.h(113,15): note: hidden overloaded virtual function 'Player::Step' declared here: different number of parameters (6 vs 7) virtual void Step(int col, ^ 1 warning generated. [234/655] Building CXX object CMakeFiles\Etterna.dir\src\Etterna\Screen\Gameplay\ScreenGameplayPractice.cpp.obj In file included from D:\dev\etterna\src\Etterna\Screen\Gameplay\ScreenGameplayPractice.cpp:2: D:\dev\etterna\src\Etterna\Screen\Gameplay/ScreenGameplayPractice.h(43,7): warning: 'ScreenGameplayPractice::SetupNoteDataFromRow' hides overloaded virtual function [-Woverloaded-virtual] void SetupNoteDataFromRow(Steps* pSteps, ^ D:\dev\etterna\src\Etterna\Screen\Gameplay/ScreenGameplay.h(111,15): note: hidden overloaded virtual function 'ScreenGameplay::SetupNoteDataFromRow' declared here: different number of parameters (2 vs 3) virtual void SetupNoteDataFromRow(Steps* pSteps, int row); ^ 1 warning generated. [289/655] Building CXX object CMakeFiles\Etterna.dir\src\arch\InputHandler\InputHandler_DirectInputHelper.cpp.obj D:\dev\etterna\src\arch\InputHandler\InputHandler_DirectInputHelper.cpp(247,11): warning: enumeration value 'KEY' not handled in switch [-Wswitch] switch (in.type) { ^~~~~~~ 1 warning generated. [297/655] Building CXX object CMakeFiles\Etterna.dir\src\arch\InputHandler\InputHandler_Win32_Pump.cpp.obj D:\dev\etterna\src\arch\InputHandler\InputHandler_Win32_Pump.cpp(84,10): warning: 218 enumeration values not handled in switch: 'KEY_SPACE', 'KEY_EXCL', 'KEY_QUOTE'... [-Wswitch] switch (di.button) { ^~~~~~~~~ 1 warning generated. [299/655] Building CXX object CMakeFiles\Etterna.dir\src\arch\InputHandler\InputHandler_DirectInput.cpp.obj D:\dev\etterna\src\arch\InputHandler\InputHandler_DirectInput.cpp(344,13): warning: enumeration value 'KEY' not handled in switch [-Wswitch] switch (in.type) { ^~~~~~~ D:\dev\etterna\src\arch\InputHandler\InputHandler_DirectInput.cpp(443,13): warning: enumeration values 'KEY' and 'HAT' not handled in switch [-Wswitch] switch (in.type) { ^~~~~~~ D:\dev\etterna\src\arch\InputHandler\InputHandler_DirectInput.cpp(921,10): warning: 225 enumeration values not handled in switch: 'KEY_SPACE', 'KEY_EXCL', 'KEY_QUOTE'... [-Wswitch] switch (button) { ^~~~~~ 3 warnings generated. [315/655] Building RC object CMakeFiles\Etterna.dir\src\archutils\Win32\WindowsResources.rc.res Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384 Copyright (C) Microsoft Corporation. All rights reserved. [336/655] Building CXX object CMakeFiles\Etterna.dir\src\arch\Sound\RageSoundDriver_WDMKS.cpp.obj D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(24,9): warning: 'dllimport' attribute only applies to functions, variables, classes, and Objective-C interfaces [-Wignored-attributes] typedef KSDDKAPI DWORD WINAPI KSCREATEPIN(HANDLE, ^ C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared\ks.h(4029,18): note: expanded from macro 'KSDDKAPI' #define KSDDKAPI DECLSPEC_IMPORT ^ C:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um\winnt.h(199,36): note: expanded from macro 'DECLSPEC_IMPORT' #define DECLSPEC_IMPORT __declspec(dllimport) ^ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(461,3): warning: jump from this goto statement to its label is a Microsoft extension [-Wmicrosoft-goto] goto error; ^ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(464,15): note: jump bypasses variable initialization KSDATARANGE* pDataRanges = (KSDATARANGE*)(pDataRangesItem + 1); ^ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(620,16): warning: suggest braces around initialization of subobject [-Wmissing-braces] GUID guid = { DEFINE_WAVEFORMATEX_GUID(pFormat->wFormatTag) }; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(13,31): note: expanded from macro 'DEFINE_WAVEFORMATEX_GUID' (USHORT)(x), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(804,10): warning: enumeration values 'NUM_DeviceSampleFormat' and 'DeviceSampleFormat_Invalid' not handled in switch [-Wswitch] switch (sampleFormat) { ^~~~~~~~~~~~ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(1130,3): warning: jump from this goto statement to its label is a Microsoft extension [-Wmicrosoft-goto] goto error; ^ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(1137,6): note: jump bypasses variable initialization int iFrameSize = 1; ^ D:\dev\etterna\src\arch\Sound\RageSoundDriver_WDMKS.cpp(1297,10): warning: enumeration values 'DeviceSampleFormat_Int16', 'NUM_DeviceSampleFormat', and 'DeviceSampleFormat_Invalid' not handled in switch [-Wswitch] switch (FromFormat) { ^~~~~~~~~~ 6 warnings generated. [441/655] Building CXX object CMakeFiles\Etterna.dir\src\Etterna\Actor\Gameplay\PlayerReplay.cpp.obj In file included from D:\dev\etterna\src\Etterna\Actor\Gameplay\PlayerReplay.cpp:15: D:\dev\etterna\src\Etterna\Actor\Gameplay/PlayerReplay.h(25,7): warning: 'PlayerReplay::Step' hides overloaded virtual function [-Woverloaded-virtual] void Step(int col, ^ D:\dev\etterna\src\Etterna\Actor\Gameplay/Player.h(113,15): note: hidden overloaded virtual function 'Player::Step' declared here: different number of parameters (6 vs 7) virtual void Step(int col, ^ 1 warning generated. [473/655] Building CXX object CMakeFiles\Etterna.dir\src\Etterna\Singletons\DownloadManager.cpp.obj D:\dev\etterna\src\Etterna\Singletons\DownloadManager.cpp(1459,12): warning: unused variable 'res' [-Wunused-variable] CURLcode res = curl_easy_perform(req->handle); ^ In file included from D:\dev\etterna\src\Etterna\Singletons\DownloadManager.cpp:22: D:\dev\etterna\extern\rapidjson\include\rapidjson/document.h(629,13): warning: unused typedef 'StaticAssertTypedef629' [-Wunused-local-typedef] RAPIDJSON_STATIC_ASSERT((internal::IsSame::Value)); ^ D:\dev\etterna\extern\rapidjson\include\rapidjson/error/../rapidjson.h(440,5): note: expanded from macro 'RAPIDJSON_STATIC_ASSERT' RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE ^ D:\dev\etterna\extern\rapidjson\include\rapidjson/error/../rapidjson.h(419,30): note: expanded from macro 'RAPIDJSON_JOIN' #define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y) ^ D:\dev\etterna\extern\rapidjson\include\rapidjson/error/../rapidjson.h(420,33): note: expanded from macro 'RAPIDJSON_DO_JOIN' #define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y) ^ D:\dev\etterna\extern\rapidjson\include\rapidjson/error/../rapidjson.h(421,34): note: expanded from macro 'RAPIDJSON_DO_JOIN2' #define RAPIDJSON_DO_JOIN2(X, Y) X##Y ^ (12,1): note: expanded from here StaticAssertTypedef629 ^ 2 warnings generated. [503/655] Building CXX object CMakeFiles\Etterna.dir\src\Etterna\Models\Fonts\Font.cpp.obj D:\dev\etterna\src\Etterna\Models\Fonts\Font.cpp(386,17): warning: result of comparison of constant 16777215 with expression of type 'wchar_t' is always false [-Wtautological-constant-out-of-range-compare] if (c < 0 || c > 0xFFFFFF) ~ ^ ~~~~~~~~ 1 warning generated. [509/655] Building CXX object CMakeFiles\Etterna.dir\src\RageUtil\Misc\RageUnicode.cpp.obj D:\dev\etterna\src\RageUtil\Misc\RageUnicode.cpp(164,14): warning: result of comparison of constant 65536 with expression of type 'wchar_t' is always true [-Wtautological-constant-out-of-range-compare] else if (ch < 0x10000) ~~ ^ ~~~~~~~ D:\dev\etterna\src\RageUtil\Misc\RageUnicode.cpp(166,14): warning: result of comparison of constant 2097152 with expression of type 'wchar_t' is always true [-Wtautological-constant-out-of-range-compare] else if (ch < 0x200000) ~~ ^ ~~~~~~~~ D:\dev\etterna\src\RageUtil\Misc\RageUnicode.cpp(168,14): warning: result of comparison of constant 67108864 with expression of type 'wchar_t' is always true [-Wtautological-constant-out-of-range-compare] else if (ch < 0x4000000) ~~ ^ ~~~~~~~~~ 3 warnings generated. [550/655] Building CXX object CMakeFiles\Etterna.dir\src\Etterna\Globals\StepMania.cpp.obj D:\dev\etterna\src\Etterna\Globals\StepMania.cpp(1479,7): warning: unused variable 'sign' [-Wunused-variable] bool sign = ^ 1 warning generated. [628/655] Building RC object extern\curl\lib\CMakeFiles\libcurl.dir\libcurl.rc.res Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384 Copyright (C) Microsoft Corporation. All rights reserved. [649/655] Building CXX object CMakeFiles\Etterna.dir\src\RageUtil\Utils\RageUtil.cpp.obj D:\dev\etterna\src\RageUtil\Utils\RageUtil.cpp(1716,14): warning: result of comparison of constant 65536 with expression of type 'wchar_t' is always true [-Wtautological-constant-out-of-range-compare] else if (ch < 0x10000) ~~ ^ ~~~~~~~ D:\dev\etterna\src\RageUtil\Utils\RageUtil.cpp(1718,14): warning: result of comparison of constant 2097152 with expression of type 'wchar_t' is always true [-Wtautological-constant-out-of-range-compare] else if (ch < 0x200000) ~~ ^ ~~~~~~~~ D:\dev\etterna\src\RageUtil\Utils\RageUtil.cpp(1720,14): warning: result of comparison of constant 67108864 with expression of type 'wchar_t' is always true [-Wtautological-constant-out-of-range-compare] else if (ch < 0x4000000) ~~ ^ ~~~~~~~~~ 3 warnings generated.

There are 2 about virtual methods (PlayerReplay::Step and ScreenGameplay::SetupNoteDataFromRow), a couple about doing wchar_t comparisons with constants that are out of range, something about a goto in RageSoundDriver_WDMKS.cpp, and a number of switches on enums that do not have cases for all possible values in InputHandler_Win32_Pump.cpp, InputHandler_DirectInputHelper.cpp, InputHandler_DirectInput.cpp and RageSoundDriver_WDMKS.cpp

I'm gonna try to fix the virtual method warnings and the switch warnings before merging this.

nico-abram commented 2 years ago

Other than the this == nullptr warnings and the ones Blue fixed, there are only a couple remaining. Among them is this one:

In file included from D:\dev\etterna\src\Etterna\Actor\Gameplay\PlayerReplay.cpp:15:
D:\dev\etterna\src\Etterna\Actor\Gameplay/PlayerReplay.h(25,7): warning: 'PlayerReplay::Step' hides overloaded virtual function [-Woverloaded-virtual]
        void Step(int col,
             ^
D:\dev\etterna\src\Etterna\Actor\Gameplay/Player.h(113,15): note: hidden overloaded virtual function 'Player::Step' declared here: different number of parameters (6 vs 7)
        virtual void Step(int col,
                     ^

I'm not sure what the best way to fix that is (Either rename the method in PlayerReplay or make their signatures match and make the PlayerReplay one override Player::Step)

poco0317 commented 1 year ago

Similar issue to #1161 where not sure about cmake changes effects

nico-abram commented 1 year ago

Removed the cmake changes since they're not necessary for this PR and fixed conflicts