controllermap: use enum to avoid '-Wmaybe-uninitialized' Emitted by MinGW: In function 'WatchJoystick', inlined from 'SDL_main' at D:/a/SDL/SDL/test/controllermap.c:802:9: D:/a/SDL/SDL/test/controllermap.c:437:9: warning: 'marker' may be used uninitialized [-Wmaybe-uninitialized] 437 | SDL_SetTextureAlphaMod(marker, alpha); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ D:/a/SDL/SDL/test/controllermap.c: In function 'SDL_main': D:/a/SDL/SDL/test/controllermap.c:355:71: note: 'marker' was declared here 355 | SDL_Texture *background_front, *background_back, *button, *axis, *marker;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/test/controllermap.c b/test/controllermap.c
index c2bee40..43bf793 100644
--- a/test/controllermap.c
+++ b/test/controllermap.c
@@ -28,8 +28,10 @@
#define SCREEN_WIDTH 512
#define SCREEN_HEIGHT 320
-#define MARKER_BUTTON 1
-#define MARKER_AXIS 2
+enum marker_type {
+ MARKER_BUTTON,
+ MARKER_AXIS,
+};
enum
{
@@ -48,11 +50,11 @@ enum
#define BINDING_COUNT (SDL_CONTROLLER_BUTTON_MAX + SDL_CONTROLLER_BINDING_AXIS_MAX)
-static struct
+static struct
{
int x, y;
double angle;
- int marker;
+ enum marker_type marker;
} s_arrBindingDisplay[] = {
{ 387, 167, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_A */
@@ -352,7 +354,7 @@ BMergeAxisBindings(int iIndex)
static void
WatchJoystick(SDL_Joystick * joystick)
{
- SDL_Texture *background_front, *background_back, *button, *axis, *marker;
+ SDL_Texture *background_front, *background_back, *button, *axis, *marker=NULL;
const char *name = NULL;
SDL_Event event;
SDL_Rect dst;
@@ -407,8 +409,6 @@ WatchJoystick(SDL_Joystick * joystick)
case MARKER_BUTTON:
marker = button;
break;
- default:
- break;
}
dst.x = s_arrBindingDisplay[iElement].x;