From d04fa0ef7665aad63b687b324a76fad3be485e4d Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 6 Oct 2022 00:30:11 +0200
Subject: [PATCH] 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;
---
test/controllermap.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/controllermap.c b/test/controllermap.c
index c2bee4016ed9..43bf79390326 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;