Browse Source

SDL_Get*Driver() functions: Set error message on failure

Petar Popovic 2 months ago
parent
commit
c16b7bcb7a
4 changed files with 4 additions and 2 deletions
  1. 1 0
      src/audio/SDL_audio.c
  2. 1 0
      src/camera/SDL_camera.c
  3. 1 2
      src/render/SDL_render.c
  4. 1 0
      src/video/SDL_video.c

+ 1 - 0
src/audio/SDL_audio.c

@@ -136,6 +136,7 @@ const char *SDL_GetAudioDriver(int index)
     if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
         return deduped_bootstrap[index]->name;
     }
+    SDL_InvalidParamError("index");
     return NULL;
 }
 

+ 1 - 0
src/camera/SDL_camera.c

@@ -74,6 +74,7 @@ const char *SDL_GetCameraDriver(int index)
     if (index >= 0 && index < SDL_GetNumCameraDrivers()) {
         return bootstrap[index]->name;
     }
+    SDL_InvalidParamError("index");
     return NULL;
 }
 

+ 1 - 2
src/render/SDL_render.c

@@ -810,8 +810,7 @@ const char *SDL_GetRenderDriver(int index)
 {
 #ifndef SDL_RENDER_DISABLED
     if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
-        SDL_SetError("index must be in the range of 0 - %d",
-                            SDL_GetNumRenderDrivers() - 1);
+        SDL_InvalidParamError("index");
         return NULL;
     }
     return render_drivers[index]->name;

+ 1 - 0
src/video/SDL_video.c

@@ -596,6 +596,7 @@ const char *SDL_GetVideoDriver(int index)
     if (index >= 0 && index < SDL_GetNumVideoDrivers()) {
         return deduped_bootstrap[index]->name;
     }
+    SDL_InvalidParamError("index");
     return NULL;
 }