Skip to content

Commit db8790c

Browse files
authored
clean-up build warnings (#1594)
* clean-up build warnings Went from 191->84 * removed too much in initial commit * Update PS4Auth.cpp * add debug compile options, fix warnings * Fixed issues found by PVS-Studio mostly initializing class members * clean redefines * xsm3 fixes mostly swapping for memcpy to fix alignment warnings validated nothing broke with 360 auth * fix redefine warnings
1 parent 5a346b7 commit db8790c

55 files changed

Lines changed: 203 additions & 190 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ add_subdirectory(lib)
182182

183183
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
184184
# Activate some compiler / linker options to aid us with diagnosing stack space issues in Debug builds
185-
add_compile_options(-fstack-usage -Wstack-usage=500)
185+
add_compile_options(-fstack-usage -Wstack-usage=500 -Wnull-dereference -Wcast-align -Wimplicit-fallthrough)
186186
add_compile_definitions(PICO_USE_STACK_GUARDS=1)
187187
endif()
188188

headers/display/GPGFX_UI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class GPGFX_UI {
2323
DisplayOptions getDisplayOptions();
2424
private:
2525
GPGFX* _renderer;
26-
DisplayOptions _displayOptions;
27-
bool _configMode;
26+
DisplayOptions _displayOptions{};
27+
bool _configMode = false;
2828
};
2929

3030
#endif

headers/display/GPGFX_UI_types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
typedef struct MenuEntry {
99
std::string label;
10-
uint8_t* icon;
11-
std::vector<MenuEntry>* submenu;
10+
uint8_t* icon = nullptr;
11+
std::vector<MenuEntry>* submenu = nullptr;
1212
std::function<int32_t()> currentValue;
1313
std::function<void()> action;
1414
int32_t optionValue = -1;

headers/display/ui/elements/GPWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class GPWidget : public GPGFX_UI {
3838

3939
uint16_t strokeColor = 0;
4040
uint16_t fillColor = 0;
41-
uint16_t _ID;
41+
uint16_t _ID = 0;
4242
uint16_t _priority = 0;
4343
bool _visibility = true;
4444

headers/display/ui/screens/ButtonLayoutScreen.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#define INPUT_HISTORY_MAX_MODES 12
1919

2020
// Static to ensure memory is never doubled
21-
static const char * displayNames[INPUT_HISTORY_MAX_MODES][INPUT_HISTORY_MAX_INPUTS] = {
21+
static const char * displayNames[INPUT_HISTORY_MAX_MODES][INPUT_HISTORY_MAX_INPUTS] __attribute__((unused)) = {
2222
{ // PS3 - 0
2323
CHAR_UP, CHAR_DOWN, CHAR_LEFT, CHAR_RIGHT,
2424
CHAR_UL, CHAR_UR, CHAR_DL, CHAR_DR,
@@ -146,35 +146,35 @@ class ButtonLayoutScreen : public GPScreen {
146146
{INPUT_MODE_GENERIC, 11},
147147
};
148148

149-
Gamepad* gamepad;
150-
InputMode inputMode;
151-
std::string statusBar;
152-
std::string footer;
149+
Gamepad* gamepad = nullptr;
150+
InputMode inputMode = INPUT_MODE_XINPUT;
151+
std::string statusBar{};
152+
std::string footer{};
153153

154154
bool isInputHistoryEnabled = false;
155155
uint16_t inputHistoryX = 0;
156156
uint16_t inputHistoryY = 0;
157157
size_t inputHistoryLength = 0;
158-
std::string historyString;
159-
std::deque<std::string> inputHistory;
160-
std::array<bool, INPUT_HISTORY_MAX_INPUTS> lastInput;
158+
std::string historyString{};
159+
std::deque<std::string> inputHistory{};
160+
std::array<bool, INPUT_HISTORY_MAX_INPUTS> lastInput{};
161161

162-
bool bannerDisplay;
162+
bool bannerDisplay = false;
163163
uint8_t bannerDelay = 2;
164164
int bannerDelayStart = 0;
165-
std::string bannerMessage;
165+
std::string bannerMessage{};
166166
uint16_t prevButtonState = 0;
167167
uint8_t prevLayoutLeft = 0;
168168
uint8_t prevLayoutRight = 0;
169169
uint8_t profileNumber = 0;
170170
uint8_t prevProfileNumber = 0;
171-
ButtonLayoutParamsLeft prevLeftOptions;
172-
ButtonLayoutParamsRight prevRightOptions;
173-
ButtonLayoutOrientation prevOrientation;
171+
ButtonLayoutParamsLeft prevLeftOptions{};
172+
ButtonLayoutParamsRight prevRightOptions{};
173+
ButtonLayoutOrientation prevOrientation{};
174174

175175
bool hasTurboAssigned = false;
176176

177-
bool macroEnabled;
177+
bool macroEnabled = false;
178178

179179
bool showInputMode = true;
180180
bool showTurboMode = true;

headers/display/ui/screens/DisplaySaverScreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class DisplaySaverScreen : public GPScreen {
1818
protected:
1919
virtual void drawScreen();
2020
uint16_t prevButtonState = 0;
21-
DisplaySaverMode displaySaverMode;
21+
DisplaySaverMode displaySaverMode{};
2222

2323
// snow screen
2424
uint8_t snowflakeSpeeds[SCREEN_WIDTH][SCREEN_HEIGHT] = {};

headers/display/ui/screens/MainMenuScreen.h

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ class MainMenuScreen : public GPScreen {
8080
virtual void drawScreen();
8181
private:
8282
bool isPressed = false;
83-
uint32_t checkDebounce;
84-
std::vector<MenuEntry>* currentMenu;
85-
std::vector<MenuEntry>* previousMenu;
83+
uint32_t checkDebounce = 0;
84+
std::vector<MenuEntry>* currentMenu = nullptr;
85+
std::vector<MenuEntry>* previousMenu = nullptr;
8686
uint16_t prevButtonState = 0;
8787
uint8_t prevDpadState = 0;
88-
Mask_t prevValues;
88+
Mask_t prevValues = 0;
8989
GPMenu* gpMenu = nullptr;
9090
const uint8_t menuLineSize = 4;
9191

92-
GpioAction eventAction;
92+
GpioAction eventAction = GpioAction::NONE;
9393

9494
bool screenIsPrompting = false;
9595
bool promptChoice = false;
@@ -98,13 +98,13 @@ class MainMenuScreen : public GPScreen {
9898
int8_t exitToScreenBeforePrompt = -1;
9999
int8_t exitToScreen = -1;
100100

101-
GamepadButtonMapping *mapMenuUp;
102-
GamepadButtonMapping *mapMenuDown;
103-
GamepadButtonMapping *mapMenuLeft;
104-
GamepadButtonMapping *mapMenuRight;
105-
GamepadButtonMapping *mapMenuSelect;
106-
GamepadButtonMapping *mapMenuBack;
107-
GamepadButtonMapping *mapMenuToggle;
101+
GamepadButtonMapping *mapMenuUp = nullptr;
102+
GamepadButtonMapping *mapMenuDown = nullptr;
103+
GamepadButtonMapping *mapMenuLeft = nullptr;
104+
GamepadButtonMapping *mapMenuRight = nullptr;
105+
GamepadButtonMapping *mapMenuSelect = nullptr;
106+
GamepadButtonMapping *mapMenuBack = nullptr;
107+
GamepadButtonMapping *mapMenuToggle = nullptr;
108108

109109
void saveOptions();
110110
void resetOptions();
@@ -118,39 +118,44 @@ class MainMenuScreen : public GPScreen {
118118
std::vector<MenuEntry> inputModeMenu = {
119119
InputMode_VALUELIST(INPUT_MODE_ENTRIES)
120120
};
121-
InputMode prevInputMode;
122-
InputMode updateInputMode;
121+
InputMode prevInputMode{};
122+
InputMode updateInputMode{};
123123

124124
std::vector<MenuEntry> dpadModeMenu = {
125125
DpadMode_VALUELIST(DPAD_MODE_ENTRIES)
126126
};
127-
DpadMode prevDpadMode;
128-
DpadMode updateDpadMode;
127+
DpadMode prevDpadMode{};
128+
DpadMode updateDpadMode{};
129129

130130
std::vector<MenuEntry> socdModeMenu = {
131131
SOCDMode_VALUELIST(SOCD_MODE_ENTRIES)
132132
};
133-
SOCDMode prevSocdMode;
134-
SOCDMode updateSocdMode;
133+
SOCDMode prevSocdMode{};
134+
SOCDMode updateSocdMode{};
135135

136136
std::vector<MenuEntry> profilesMenu = {};
137-
uint8_t prevProfile;
138-
uint8_t updateProfile;
137+
uint8_t prevProfile{};
138+
uint8_t updateProfile{};
139139

140140
std::vector<MenuEntry> focusModeMenu = {
141141
{"Off", NULL, nullptr, std::bind(&MainMenuScreen::currentFocusMode, this), std::bind(&MainMenuScreen::selectFocusMode, this), 0},
142142
{"On", NULL, nullptr, std::bind(&MainMenuScreen::currentFocusMode, this), std::bind(&MainMenuScreen::selectFocusMode, this), 1},
143143
};
144-
bool prevFocus;
145-
bool updateFocus;
144+
bool prevFocus = false;
145+
bool updateFocus = false;
146146

147147
std::vector<MenuEntry> turboModeMenu = {
148148
{"Off", NULL, nullptr, std::bind(&MainMenuScreen::currentTurboMode, this), std::bind(&MainMenuScreen::selectTurboMode, this), 0},
149149
{"On", NULL, nullptr, std::bind(&MainMenuScreen::currentTurboMode, this), std::bind(&MainMenuScreen::selectTurboMode, this), 1},
150150
};
151-
bool prevTurbo;
152-
bool updateTurbo;
151+
bool prevTurbo = false;
152+
bool updateTurbo = false;
153153

154+
std::vector<MenuEntry> saveMenu = {
155+
{"Save & Exit",NULL, nullptr, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::saveAndExit, this), 1},
156+
{"Exit", NULL, nullptr, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::exitOnly, this), 0},
157+
};
158+
154159
std::vector<MenuEntry> mainMenu = {
155160
{"Input Mode", NULL, &inputModeMenu, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::testMenu, this)},
156161
{"D-Pad Mode", NULL, &dpadModeMenu, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::testMenu, this)},
@@ -161,10 +166,7 @@ class MainMenuScreen : public GPScreen {
161166
{"Exit", NULL, &saveMenu, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::testMenu, this)},
162167
};
163168

164-
std::vector<MenuEntry> saveMenu = {
165-
{"Save & Exit",NULL, nullptr, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::saveAndExit, this), 1},
166-
{"Exit", NULL, nullptr, std::bind(&MainMenuScreen::modeValue, this), std::bind(&MainMenuScreen::exitOnly, this), 0},
167-
};
169+
168170
};
169171

170172
#endif

headers/display/ui/screens/RestartScreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class RestartScreen : public GPScreen {
1515
void setBootMode(uint32_t mode);
1616
protected:
1717
virtual void drawScreen();
18-
uint32_t bootMode;
18+
uint32_t bootMode = 0;
1919
};
2020

2121
#endif

headers/display/ui/screens/SplashScreen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SplashScreen : public GPScreen {
1515
virtual void drawScreen();
1616
uint16_t prevButtonState = 0;
1717
uint32_t splashStartTime = 0;
18-
bool configMode;
18+
bool configMode = false;
1919
};
2020

2121
#endif

headers/display/ui/screens/StatsScreen.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ class StatsScreen : public GPScreen {
1515
virtual void drawScreen();
1616
uint16_t prevButtonState = 0;
1717

18-
GPLabel* header;
19-
GPLabel* version;
20-
GPLabel* build;
21-
GPLabel* board;
22-
GPLabel* boardType;
23-
GPLabel* arch;
24-
GPLabel* exit;
18+
GPLabel* header = nullptr;
19+
GPLabel* version = nullptr;
20+
GPLabel* build = nullptr;
21+
GPLabel* board = nullptr;
22+
GPLabel* boardType = nullptr;
23+
GPLabel* arch = nullptr;
24+
GPLabel* exit = nullptr;
2525
};
2626

2727
#endif

0 commit comments

Comments
 (0)