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;
This commit is contained in:
Anonymous Maarten 2022-10-06 00:30:11 +02:00 committed by Anonymous Maarten
parent a905db9d65
commit d04fa0ef76
1 changed files with 7 additions and 7 deletions

View File

@ -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;