diff --git a/test/checkkeys.c b/test/checkkeys.c index bc4d7f126..89bae8eee 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -35,7 +35,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index 23b93ebea..f245bc965 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -33,7 +33,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void diff --git a/test/loopwave.c b/test/loopwave.c index 7ebb01477..ac5f84d35 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -41,7 +41,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c index b28c6a8fc..e8c4daaab 100644 --- a/test/loopwavequeue.c +++ b/test/loopwavequeue.c @@ -40,7 +40,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static int done = 0; diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index 333823cb0..61047a562 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -42,7 +42,10 @@ quit(int rc) { SDL_Quit(); SDLTest_CommonDestroyState(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void SDLCALL diff --git a/test/testautomation.c b/test/testautomation.c index a017f4819..dab400902 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -52,7 +52,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } int main(int argc, char *argv[]) diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index 9438613a6..12d54208c 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -144,7 +144,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void loop(void) diff --git a/test/testdropfile.c b/test/testdropfile.c index bb85afb50..acb016122 100644 --- a/test/testdropfile.c +++ b/test/testdropfile.c @@ -22,7 +22,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } int main(int argc, char *argv[]) diff --git a/test/testerror.c b/test/testerror.c index 0b3c6541c..b52c206c8 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -25,7 +25,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static int SDLCALL diff --git a/test/testgeometry.c b/test/testgeometry.c index e262ace8a..d494d9560 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -38,7 +38,10 @@ quit(int rc) { SDL_free(sprites); SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static int LoadSprite(const char *file) diff --git a/test/testgl.c b/test/testgl.c index 21617c1bd..5cd03f9c1 100644 --- a/test/testgl.c +++ b/test/testgl.c @@ -65,7 +65,10 @@ static void quit(int rc) SDL_GL_DeleteContext(context); } SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void Render(void) diff --git a/test/testgles.c b/test/testgles.c index ecaa9d251..0afae5428 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -43,7 +43,10 @@ quit(int rc) } SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void diff --git a/test/testgles2.c b/test/testgles2.c index 7ea006992..b4ed5fe3c 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -100,7 +100,10 @@ quit(int rc) } SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } #define GL_CHECK(x) \ diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index 771091b4c..f0396bdb0 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -102,7 +102,10 @@ quit(int rc) } SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } #define GL_CHECK(x) \ diff --git a/test/testlock.c b/test/testlock.c index dd9c942e7..e9fd8bf22 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -65,7 +65,10 @@ static void closemutex(int sig) threads = NULL; } SDL_DestroyMutex(mutex); - exit(sig); + /* Let 'main()' return normally */ + if (sig != 0) { + exit(sig); + } } static int SDLCALL @@ -100,7 +103,7 @@ Run(void *data) } #ifndef _WIN32 -Uint32 hit_timeout(Uint32 interval, void *param) { +static Uint32 hit_timeout(Uint32 interval, void *param) { SDL_Log("Hit timeout! Sending SIGINT!"); kill(0, SIGINT); return 0; diff --git a/test/testmessage.c b/test/testmessage.c index 587a110ad..c490787d3 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -23,7 +23,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static int SDLCALL diff --git a/test/testnative.c b/test/testnative.c index a58ce3ad5..ef587ede7 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -52,7 +52,10 @@ quit(int rc) factory->DestroyNativeWindow(native_window); } SDLTest_CommonDestroyState(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite) diff --git a/test/testoverlay.c b/test/testoverlay.c index 6b9adefa5..abd97c40a 100644 --- a/test/testoverlay.c +++ b/test/testoverlay.c @@ -176,9 +176,9 @@ quit(int rc) SDLTest_CommonQuit(state); - + /* Let 'main()' return normally */ if (rc != 0) { - exit(rc); + exit(rc); } } diff --git a/test/testpopup.c b/test/testpopup.c index 475023642..6ce0b0bd5 100644 --- a/test/testpopup.c +++ b/test/testpopup.c @@ -47,8 +47,8 @@ struct PopupWindow int idx; }; -struct PopupWindow *menus; -struct PopupWindow tooltip; +static struct PopupWindow *menus; +static struct PopupWindow tooltip; /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void quit(int rc) @@ -57,7 +57,10 @@ static void quit(int rc) menus = NULL; SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static int get_menu_index_by_window(SDL_Window *window) @@ -115,7 +118,7 @@ static SDL_bool create_popup(struct PopupWindow *new_popup, SDL_bool is_menu) return SDL_FALSE; } -static void close_popups() +static void close_popups(void) { int i; @@ -135,7 +138,7 @@ static void close_popups() } } -static void loop() +static void loop(void) { int i; char fmt_str[128]; diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index 4c166a418..ffb522957 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -41,7 +41,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void Draw(DrawState *s) diff --git a/test/testrendertarget.c b/test/testrendertarget.c index 19b07fba2..abaf09c66 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -42,7 +42,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static SDL_bool diff --git a/test/testscale.c b/test/testscale.c index 1fa2975b2..16acb3f83 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -41,7 +41,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void Draw(DrawState *s) diff --git a/test/testsem.c b/test/testsem.c index 0010fcd13..a1706ca84 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -256,7 +256,7 @@ int main(int argc, char **argv) { int arg_count = 0; int i; - int init_sem; + int init_sem = 0; SDLTest_CommonState *state; /* Initialize test framework */ diff --git a/test/testsprite.c b/test/testsprite.c index d1cbac14a..68b3b7b2d 100644 --- a/test/testsprite.c +++ b/test/testsprite.c @@ -57,9 +57,7 @@ quit(int rc) SDL_free(positions); SDL_free(velocities); SDLTest_CommonQuit(state); - /* If rc is 0, just let main return normally rather than calling exit. - * This allows testing of platforms where SDL_main is required and does meaningful cleanup. - */ + /* Let 'main()' return normally */ if (rc != 0) { exit(rc); } diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 7a837de1b..b58d21d6e 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -40,7 +40,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void MoveSprites(void) diff --git a/test/teststreaming.c b/test/teststreaming.c index 4c6499649..dcd5b4423 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -64,13 +64,16 @@ static SDL_Renderer *renderer; static int frame; static SDL_Texture *MooseTexture; static SDL_bool done = SDL_FALSE; -SDLTest_CommonState *state; +static SDLTest_CommonState *state; static void quit(int rc) { SDL_Quit(); SDLTest_CommonDestroyState(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void UpdateTexture(SDL_Texture *texture) diff --git a/test/testthread.c b/test/testthread.c index 15297e320..78560f928 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -22,7 +22,7 @@ static SDL_TLSID tls; static int alive = 0; static int testprio = 0; -SDLTest_CommonState *state; +static SDLTest_CommonState *state; /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ static void @@ -30,7 +30,10 @@ quit(int rc) { SDLTest_CommonDestroyState(state); SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static const char * diff --git a/test/testviewport.c b/test/testviewport.c index 004f3f047..006d3c244 100644 --- a/test/testviewport.c +++ b/test/testviewport.c @@ -38,7 +38,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void DrawOnViewport(SDL_Renderer *renderer) diff --git a/test/testvulkan.c b/test/testvulkan.c index 8eb98c986..dede60e94 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -187,7 +187,10 @@ static void quit(int rc) { shutdownVulkan(SDL_TRUE); SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static void loadGlobalFunctions(void) diff --git a/test/testwm.c b/test/testwm.c index 66a0df4fb..8066aa3af 100644 --- a/test/testwm.c +++ b/test/testwm.c @@ -47,7 +47,10 @@ static void quit(int rc) { SDLTest_CommonQuit(state); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } /* Draws the modes menu, and stores the mode index under the mouse in highlighted_mode */ diff --git a/test/torturethread.c b/test/torturethread.c index 4b8eeba5a..c2a0dd1a8 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -28,7 +28,10 @@ static void quit(int rc) { SDL_Quit(); - exit(rc); + /* Let 'main()' return normally */ + if (rc != 0) { + exit(rc); + } } static int SDLCALL