Commit d080e3bf3a581035d4d078f52803fc60b2504817

Pierre Wendling 2022-11-14T17:56:48

Silence `-Wmaybe-uninitialized` warnings in tests.

diff --git a/test/controllermap.c b/test/controllermap.c
index 5905b8a..22ab19e 100644
--- a/test/controllermap.c
+++ b/test/controllermap.c
@@ -611,7 +611,7 @@ WatchJoystick(SDL_Joystick * joystick)
                 SDL_GameControllerButton eButton = (SDL_GameControllerButton)iIndex;
                 SDL_strlcat(mapping, SDL_GameControllerGetStringForButton(eButton), SDL_arraysize(mapping));
             } else {
-                const char *pszAxisName;
+                const char *pszAxisName = NULL;
                 switch (iIndex - SDL_CONTROLLER_BUTTON_MAX) {
                 case SDL_CONTROLLER_BINDING_AXIS_LEFTX_NEGATIVE:
                     if (!BMergeAxisBindings(iIndex)) {
@@ -660,7 +660,9 @@ WatchJoystick(SDL_Joystick * joystick)
                     pszAxisName = SDL_GameControllerGetStringForAxis(SDL_CONTROLLER_AXIS_TRIGGERRIGHT);
                     break;
                 }
-                SDL_strlcat(mapping, pszAxisName, SDL_arraysize(mapping));
+                if (pszAxisName) {
+                    SDL_strlcat(mapping, pszAxisName, SDL_arraysize(mapping));
+                }
             }
             SDL_strlcat(mapping, ":", SDL_arraysize(mapping));
 
diff --git a/test/testautomation_pixels.c b/test/testautomation_pixels.c
index 63b177f..8117c11 100644
--- a/test/testautomation_pixels.c
+++ b/test/testautomation_pixels.c
@@ -330,6 +330,7 @@ pixels_allocFreePalette(void *arg)
   for (variation = 1; variation <= 3; variation++) {
     switch (variation) {
       /* Just one color */
+      default:
       case 1:
         ncolors = 1;
         break;
@@ -426,6 +427,7 @@ pixels_calcGammaRamp(void *arg)
   for (variation = 0; variation < 4; variation++) {
     switch (variation) {
       /* gamma = 0 all black */
+      default:
       case 0:
         gamma = 0.0f;
         break;
diff --git a/test/testautomation_rwops.c b/test/testautomation_rwops.c
index 16d5407..687ff75 100644
--- a/test/testautomation_rwops.c
+++ b/test/testautomation_rwops.c
@@ -616,6 +616,7 @@ rwops_testFileWriteReadEndian(void)
 
      /* Create test data */
      switch (mode) {
+       default:
        case 0:
         SDLTest_Log("All 0 values");
         BE16value = 0;
diff --git a/test/testautomation_video.c b/test/testautomation_video.c
index bf0283b..8d248bf 100644
--- a/test/testautomation_video.c
+++ b/test/testautomation_video.c
@@ -123,6 +123,7 @@ video_createWindowVariousPositions(void *arg)
   for (xVariation = 0; xVariation < 6; xVariation++) {
    for (yVariation = 0; yVariation < 6; yVariation++) {
     switch(xVariation) {
+     default:
      case 0:
       /* Zero X Position */
       x = 0;
@@ -150,6 +151,7 @@ video_createWindowVariousPositions(void *arg)
     }
 
     switch(yVariation) {
+     default:
      case 0:
       /* Zero X Position */
       y = 0;
@@ -267,6 +269,7 @@ video_createWindowVariousFlags(void *arg)
 
   for (fVariation = 0; fVariation < 14; fVariation++) {
     switch(fVariation) {
+     default:
      case 0:
       flags = SDL_WINDOW_FULLSCREEN;
       /* Skip - blanks screen; comment out next line to run test */
@@ -1074,6 +1077,7 @@ video_getSetWindowPosition(void *arg)
   for (xVariation = 0; xVariation < 4; xVariation++) {
    for (yVariation = 0; yVariation < 4; yVariation++) {
     switch(xVariation) {
+     default:
      case 0:
       /* Zero X Position */
       desiredX = 0;
@@ -1093,6 +1097,7 @@ video_getSetWindowPosition(void *arg)
     }
 
     switch(yVariation) {
+     default:
      case 0:
       /* Zero X Position */
       desiredY = 0;
@@ -1236,6 +1241,7 @@ video_getSetWindowSize(void *arg)
   for (wVariation = 0; wVariation < maxwVariation; wVariation++) {
    for (hVariation = 0; hVariation < maxhVariation; hVariation++) {
     switch(wVariation) {
+     default:
      case 0:
       /* 1 Pixel Wide */
       desiredW = 1;
@@ -1259,6 +1265,7 @@ video_getSetWindowSize(void *arg)
     }
 
     switch(hVariation) {
+     default:
      case 0:
       /* 1 Pixel High */
       desiredH = 1;