SDL: Remove more reserved identifiers (#6925)

From d7d3c22dbfb2b929192d6bc30dcb31b96e8fa794 Mon Sep 17 00:00:00 2001
From: Sylvain Becker <[EMAIL REDACTED]>
Date: Thu, 29 Dec 2022 22:58:16 +0100
Subject: [PATCH] Remove more reserved identifiers  (#6925)

---
 include/SDL3/SDL_assert.h                   |   2 +-
 include/SDL3/SDL_begin_code.h               |  10 +-
 include/SDL3/SDL_endian.h                   |   6 +-
 include/SDL3/SDL_stdinc.h                   |   8 +-
 src/audio/SDL_audiodev.c                    |  22 +--
 src/core/linux/SDL_fcitx.c                  |   2 +-
 src/core/linux/SDL_ime.c                    |  30 ++--
 src/events/SDL_events.c                     |  10 +-
 src/joystick/apple/SDL_mfijoystick.m        |   2 +-
 src/joystick/hidapi/SDL_hidapijoystick_c.h  |  14 +-
 src/joystick/windows/SDL_rawinputjoystick.c |   4 +-
 src/sensor/SDL_sensor_c.h                   |   2 +-
 src/sensor/SDL_syssensor.h                  |   4 +-
 src/timer/SDL_timer.c                       |  12 +-
 src/video/kmsdrm/SDL_kmsdrmmouse.h          |   2 +-
 test/testautomation_audio.c                 | 120 +++++++--------
 test/testautomation_events.c                |  60 ++++----
 test/testautomation_hints.c                 |  36 ++---
 test/testautomation_keyboard.c              |  38 ++---
 test/testautomation_mouse.c                 |  52 +++----
 test/testautomation_pixels.c                |  62 ++++----
 test/testautomation_platform.c              |  10 +-
 test/testautomation_rect.c                  | 120 +++++++--------
 test/testautomation_render.c                | 150 +++++++++---------
 test/testautomation_rwops.c                 |  10 +-
 test/testautomation_surface.c               |  36 ++---
 test/testautomation_timer.c                 |  36 ++---
 test/testautomation_video.c                 | 160 ++++++++++----------
 test/testgles2.c                            |  16 +-
 29 files changed, 518 insertions(+), 518 deletions(-)

diff --git a/include/SDL3/SDL_assert.h b/include/SDL3/SDL_assert.h
index f1b2687af2c7..cbcaa516a798 100644
--- a/include/SDL3/SDL_assert.h
+++ b/include/SDL3/SDL_assert.h
@@ -51,7 +51,7 @@ assert can have unique static variables associated with it.
 /* Don't include intrin.h here because it contains C++ code */
     extern void __cdecl __debugbreak(void);
     #define SDL_TriggerBreakpoint() __debugbreak()
-#elif _SDL_HAS_BUILTIN(__builtin_debugtrap)
+#elif SDL_HAS_BUILTIN(__builtin_debugtrap)
     #define SDL_TriggerBreakpoint() __builtin_debugtrap()
 #elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
     #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" )
diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h
index 82aa3e817942..5f77da84b6d3 100644
--- a/include/SDL3/SDL_begin_code.h
+++ b/include/SDL3/SDL_begin_code.h
@@ -154,18 +154,18 @@
 #define SDL_FALLTHROUGH [[fallthrough]]
 #else
 #if defined(__has_attribute)
-#define _HAS_FALLTHROUGH __has_attribute(__fallthrough__)
+#define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__)
 #else
-#define _HAS_FALLTHROUGH 0
+#define SDL_HAS_FALLTHROUGH 0
 #endif /* __has_attribute */
-#if _HAS_FALLTHROUGH && \
+#if SDL_HAS_FALLTHROUGH && \
    ((defined(__GNUC__) && __GNUC__ >= 7) || \
     (defined(__clang_major__) && __clang_major__ >= 10))
 #define SDL_FALLTHROUGH __attribute__((__fallthrough__))
 #else
 #define SDL_FALLTHROUGH do {} while (0) /* fallthrough */
-#endif /* _HAS_FALLTHROUGH */
-#undef _HAS_FALLTHROUGH
+#endif /* SDL_HAS_FALLTHROUGH */
+#undef SDL_HAS_FALLTHROUGH
 #endif /* C++17 or C2x */
 #endif /* SDL_FALLTHROUGH not defined */
 
diff --git a/include/SDL3/SDL_endian.h b/include/SDL3/SDL_endian.h
index f95c6f783aa6..bcd0854d8ce3 100644
--- a/include/SDL3/SDL_endian.h
+++ b/include/SDL3/SDL_endian.h
@@ -122,11 +122,11 @@ extern "C" {
 
 /* various modern compilers may have builtin swap */
 #if defined(__GNUC__) || defined(__clang__)
-#   define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \
+#   define HAS_BUILTIN_BSWAP16 (SDL_HAS_BUILTIN(__builtin_bswap16)) || \
         (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
-#   define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \
+#   define HAS_BUILTIN_BSWAP32 (SDL_HAS_BUILTIN(__builtin_bswap32)) || \
         (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
-#   define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \
+#   define HAS_BUILTIN_BSWAP64 (SDL_HAS_BUILTIN(__builtin_bswap64)) || \
         (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
 
     /* this one is broken */
diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h
index 444c7d52abb8..75df76aae00d 100644
--- a/include/SDL3/SDL_stdinc.h
+++ b/include/SDL3/SDL_stdinc.h
@@ -72,9 +72,9 @@ char *alloca();
  * instead of checking the clang version if possible.
  */
 #ifdef __has_builtin
-#define _SDL_HAS_BUILTIN(x) __has_builtin(x)
+#define SDL_HAS_BUILTIN(x) __has_builtin(x)
 #else
-#define _SDL_HAS_BUILTIN(x) 0
+#define SDL_HAS_BUILTIN(x) 0
 #endif
 
 /**
@@ -694,7 +694,7 @@ SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a,
     return 0;
 }
 
-#if _SDL_HAS_BUILTIN(__builtin_mul_overflow)
+#if SDL_HAS_BUILTIN(__builtin_mul_overflow)
 /* This needs to be wrapped in an inline rather than being a direct #define,
  * because __builtin_mul_overflow() is type-generic, but we want to be
  * consistent about interpreting a and b as size_t. */
@@ -724,7 +724,7 @@ SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a,
     return 0;
 }
 
-#if _SDL_HAS_BUILTIN(__builtin_add_overflow)
+#if SDL_HAS_BUILTIN(__builtin_add_overflow)
 /* This needs to be wrapped in an inline rather than being a direct #define,
  * the same as the call to __builtin_mul_overflow() above. */
 SDL_FORCE_INLINE int SDL_size_add_overflow_builtin (size_t a,
diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c
index cb842093ffaf..4c2a8151984e 100644
--- a/src/audio/SDL_audiodev.c
+++ b/src/audio/SDL_audiodev.c
@@ -31,18 +31,18 @@
 
 #include "SDL_audiodev_c.h"
 
-#ifndef _PATH_DEV_DSP
+#ifndef SDL_PATH_DEV_DSP
 #if defined(__NETBSD__) || defined(__OPENBSD__)
-#define _PATH_DEV_DSP "/dev/audio"
+#define SDL_PATH_DEV_DSP "/dev/audio"
 #else
-#define _PATH_DEV_DSP "/dev/dsp"
+#define SDL_PATH_DEV_DSP "/dev/dsp"
 #endif
 #endif
-#ifndef _PATH_DEV_DSP24
-#define _PATH_DEV_DSP24 "/dev/sound/dsp"
+#ifndef SDL_PATH_DEV_DSP24
+#define SDL_PATH_DEV_DSP24 "/dev/sound/dsp"
 #endif
-#ifndef _PATH_DEV_AUDIO
-#define _PATH_DEV_AUDIO "/dev/audio"
+#ifndef SDL_PATH_DEV_AUDIO
+#define SDL_PATH_DEV_AUDIO "/dev/audio"
 #endif
 
 static void test_device(const int iscapture, const char *fname, int flags, int (*test)(int fd))
@@ -91,15 +91,15 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
     }
     if (audiodev == NULL) {
         if (classic) {
-            audiodev = _PATH_DEV_AUDIO;
+            audiodev = SDL_PATH_DEV_AUDIO;
         } else {
             struct stat sb;
 
             /* Added support for /dev/sound/\* in Linux 2.4 */
-            if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) {
-                audiodev = _PATH_DEV_DSP24;
+            if (((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) && ((stat(SDL_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode))) {
+                audiodev = SDL_PATH_DEV_DSP24;
             } else {
-                audiodev = _PATH_DEV_DSP;
+                audiodev = SDL_PATH_DEV_DSP;
             }
         }
     }
diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c
index cf51ac438d85..5b9afcd3b60a 100644
--- a/src/core/linux/SDL_fcitx.c
+++ b/src/core/linux/SDL_fcitx.c
@@ -41,7 +41,7 @@
 
 #define DBUS_TIMEOUT 500
 
-typedef struct _FcitxClient
+typedef struct FcitxClient
 {
     SDL_DBusContext *dbus;
 
diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c
index 4740dd0e6ea8..13cd03583845 100644
--- a/src/core/linux/SDL_ime.c
+++ b/src/core/linux/SDL_ime.c
@@ -24,21 +24,21 @@
 #include "SDL_ibus.h"
 #include "SDL_fcitx.h"
 
-typedef SDL_bool (*_SDL_IME_Init)(void);
-typedef void (*_SDL_IME_Quit)(void);
-typedef void (*_SDL_IME_SetFocus)(SDL_bool);
-typedef void (*_SDL_IME_Reset)(void);
-typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32, Uint8 state);
-typedef void (*_SDL_IME_UpdateTextRect)(const SDL_Rect *);
-typedef void (*_SDL_IME_PumpEvents)(void);
-
-static _SDL_IME_Init SDL_IME_Init_Real = NULL;
-static _SDL_IME_Quit SDL_IME_Quit_Real = NULL;
-static _SDL_IME_SetFocus SDL_IME_SetFocus_Real = NULL;
-static _SDL_IME_Reset SDL_IME_Reset_Real = NULL;
-static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL;
-static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL;
-static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL;
+typedef SDL_bool (*SDL_IME_Init_t)(void);
+typedef void (*SDL_IME_Quit_t)(void);
+typedef void (*SDL_IME_SetFocus_t)(SDL_bool);
+typedef void (*SDL_IME_Reset_t)(void);
+typedef SDL_bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
+typedef void (*SDL_IME_UpdateTextRect_t)(const SDL_Rect *);
+typedef void (*SDL_IME_PumpEvents_t)(void);
+
+static SDL_IME_Init_t SDL_IME_Init_Real = NULL;
+static SDL_IME_Quit_t SDL_IME_Quit_Real = NULL;
+static SDL_IME_SetFocus_t SDL_IME_SetFocus_Real = NULL;
+static SDL_IME_Reset_t SDL_IME_Reset_Real = NULL;
+static SDL_IME_ProcessKeyEvent_t SDL_IME_ProcessKeyEvent_Real = NULL;
+static SDL_IME_UpdateTextRect_t SDL_IME_UpdateTextRect_Real = NULL;
+static SDL_IME_PumpEvents_t SDL_IME_PumpEvents_Real = NULL;
 
 static void InitIME()
 {
diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index c4f060a34137..4ca6fd09b4df 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -68,18 +68,18 @@ static SDL_DisabledEventBlock *SDL_disabled_events[256];
 static Uint32 SDL_userevents = SDL_USEREVENT;
 
 /* Private data -- event queue */
-typedef struct _SDL_EventEntry
+typedef struct SDL_EventEntry
 {
     SDL_Event event;
     SDL_SysWMmsg msg;
-    struct _SDL_EventEntry *prev;
-    struct _SDL_EventEntry *next;
+    struct SDL_EventEntry *prev;
+    struct SDL_EventEntry *next;
 } SDL_EventEntry;
 
-typedef struct _SDL_SysWMEntry
+typedef struct SDL_SysWMEntry
 {
     SDL_SysWMmsg msg;
-    struct _SDL_SysWMEntry *next;
+    struct SDL_SysWMEntry *next;
 } SDL_SysWMEntry;
 
 static struct
diff --git a/src/joystick/apple/SDL_mfijoystick.m b/src/joystick/apple/SDL_mfijoystick.m
index c460314494c9..64fcf53bf58b 100644
--- a/src/joystick/apple/SDL_mfijoystick.m
+++ b/src/joystick/apple/SDL_mfijoystick.m
@@ -622,7 +622,7 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char
 static int IOS_JoystickInit(void)
 {
 #if defined(__MACOS__)
-#if _SDL_HAS_BUILTIN(__builtin_available)
+#if SDL_HAS_BUILTIN(__builtin_available)
     if (@available(macOS 10.16, *)) {
         /* Continue with initialization on macOS 11+ */
     } else {
diff --git a/src/joystick/hidapi/SDL_hidapijoystick_c.h b/src/joystick/hidapi/SDL_hidapijoystick_c.h
index c0ecab08da9c..aa590e40ea5c 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick_c.h
+++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h
@@ -46,9 +46,9 @@
 #define USB_PACKET_LENGTH 64
 
 /* Forward declaration */
-struct _SDL_HIDAPI_DeviceDriver;
+struct SDL_HIDAPI_DeviceDriver;
 
-typedef struct _SDL_HIDAPI_Device
+typedef struct SDL_HIDAPI_Device
 {
     char *name;
     char *path;
@@ -67,7 +67,7 @@ typedef struct _SDL_HIDAPI_Device
     SDL_JoystickType joystick_type;
     SDL_GamepadType type;
 
-    struct _SDL_HIDAPI_DeviceDriver *driver;
+    struct SDL_HIDAPI_DeviceDriver *driver;
     void *context;
     SDL_mutex *dev_lock;
     SDL_hid_device *dev;
@@ -81,14 +81,14 @@ typedef struct _SDL_HIDAPI_Device
     /* Used to flag that the device is being updated */
     SDL_bool updating;
 
-    struct _SDL_HIDAPI_Device *parent;
+    struct SDL_HIDAPI_Device *parent;
     int num_children;
-    struct _SDL_HIDAPI_Device **children;
+    struct SDL_HIDAPI_Device **children;
 
-    struct _SDL_HIDAPI_Device *next;
+    struct SDL_HIDAPI_Device *next;
 } SDL_HIDAPI_Device;
 
-typedef struct _SDL_HIDAPI_DeviceDriver
+typedef struct SDL_HIDAPI_DeviceDriver
 {
     const char *name;
     SDL_bool enabled;
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index e5d29e14be80..5d57d49a054f 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -93,7 +93,7 @@ static int SDL_RAWINPUT_numjoysticks = 0;
 
 static void RAWINPUT_JoystickClose(SDL_Joystick *joystick);
 
-typedef struct _SDL_RAWINPUT_Device
+typedef struct SDL_RAWINPUT_Device
 {
     SDL_atomic_t refcount;
     char *name;
@@ -110,7 +110,7 @@ typedef struct _SDL_RAWINPUT_Device
     SDL_Joystick *joystick;
     SDL_JoystickID joystick_id;
 
-    struct _SDL_RAWINPUT_Device *next;
+    struct SDL_RAWINPUT_Device *next;
 } SDL_RAWINPUT_Device;
 
 struct joystick_hwdata
diff --git a/src/sensor/SDL_sensor_c.h b/src/sensor/SDL_sensor_c.h
index 814e9367485e..d6cb5118030e 100644
--- a/src/sensor/SDL_sensor_c.h
+++ b/src/sensor/SDL_sensor_c.h
@@ -23,7 +23,7 @@
 #ifndef SDL_sensor_c_h_
 #define SDL_sensor_c_h_
 
-struct _SDL_SensorDriver;
+struct SDL_SensorDriver;
 
 /* Useful functions and variables from SDL_sensor.c */
 
diff --git a/src/sensor/SDL_syssensor.h b/src/sensor/SDL_syssensor.h
index c84a8f0684f6..8bf16cc7a5f8 100644
--- a/src/sensor/SDL_syssensor.h
+++ b/src/sensor/SDL_syssensor.h
@@ -37,7 +37,7 @@ struct SDL_Sensor
 
     float data[16];             /* The current state of the sensor */
 
-    struct _SDL_SensorDriver *driver;
+    struct SDL_SensorDriver *driver;
 
     struct sensor_hwdata *hwdata; /* Driver dependent information */
 
@@ -46,7 +46,7 @@ struct SDL_Sensor
     struct SDL_Sensor *next; /* pointer to next sensor we have allocated */
 };
 
-typedef struct _SDL_SensorDriver
+typedef struct SDL_SensorDriver
 {
     /* Function to scan the system for sensors.
      * sensor 0 should be the system default sensor.
diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c
index a50b05679172..cfce14edc53a 100644
--- a/src/timer/SDL_timer.c
+++ b/src/timer/SDL_timer.c
@@ -27,7 +27,7 @@
 
 #if !defined(__EMSCRIPTEN__) || !SDL_THREADS_DISABLED
 
-typedef struct _SDL_Timer
+typedef struct SDL_Timer
 {
     int timerID;
     SDL_TimerCallback callback;
@@ -35,14 +35,14 @@ typedef struct _SDL_Timer
     Uint64 interval;
     Uint64 scheduled;
     SDL_atomic_t canceled;
-    struct _SDL_Timer *next;
+    struct SDL_Timer *next;
 } SDL_Timer;
 
-typedef struct _SDL_TimerMap
+typedef struct SDL_TimerMap
 {
     int timerID;
     SDL_Timer *timer;
-    struct _SDL_TimerMap *next;
+    struct SDL_TimerMap *next;
 } SDL_TimerMap;
 
 /* The timers are kept in a sorted list */
@@ -370,14 +370,14 @@ SDL_bool SDL_RemoveTimer(SDL_TimerID id)
 #include <emscripten/emscripten.h>
 #include <emscripten/eventloop.h>
 
-typedef struct _SDL_TimerMap
+typedef struct SDL_TimerMap
 {
     int timerID;
     int timeoutID;
     Uint32 interval;
     SDL_TimerCallback callback;
     void *param;
-    struct _SDL_TimerMap *next;
+    struct SDL_TimerMap *next;
 } SDL_TimerMap;
 
 typedef struct
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.h b/src/video/kmsdrm/SDL_kmsdrmmouse.h
index 3e7a9b8d2938..920bd3354d0f 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.h
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.h
@@ -29,7 +29,7 @@
 #define MAX_CURSOR_W 512
 #define MAX_CURSOR_H 512
 
-typedef struct _KMSDRM_CursorData
+typedef struct KMSDRM_CursorData
 {
     int hot_x, hot_y;
     int w, h;
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index c84ababcaba0..bd35872ea868 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -17,7 +17,7 @@
 
 /* Fixture */
 
-void _audioSetUp(void *arg)
+static void audioSetUp(void *arg)
 {
     /* Start SDL audio subsystem */
     int ret = SDL_InitSubSystem(SDL_INIT_AUDIO);
@@ -28,7 +28,7 @@ void _audioSetUp(void *arg)
     }
 }
 
-void _audioTearDown(void *arg)
+static void audioTearDown(void *arg)
 {
     /* Remove a possibly created file from SDL disk writer audio driver; ignore errors */
     (void)remove("sdlaudio.raw");
@@ -37,17 +37,17 @@ void _audioTearDown(void *arg)
 }
 
 /* Global counter for callback invocation */
-int _audio_testCallbackCounter;
+static int g_audio_testCallbackCounter;
 
 /* Global accumulator for total callback length */
-int _audio_testCallbackLength;
+static int g_audio_testCallbackLength;
 
 /* Test callback function */
-void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len)
+static void SDLCALL audio_testCallback(void *userdata, Uint8 *stream, int len)
 {
     /* track that callback was called */
-    _audio_testCallbackCounter++;
-    _audio_testCallbackLength += len;
+    g_audio_testCallbackCounter++;
+    g_audio_testCallbackLength += len;
 }
 
 /* Test case functions */
@@ -65,7 +65,7 @@ int audio_quitInitAudioSubSystem()
     SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
 
     /* Restart audio again */
-    _audioSetUp(NULL);
+    audioSetUp(NULL);
 
     return TEST_COMPLETED;
 }
@@ -121,7 +121,7 @@ int audio_initQuitAudio()
     SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
 
     /* Restart audio again */
-    _audioSetUp(NULL);
+    audioSetUp(NULL);
 
     return TEST_COMPLETED;
 }
@@ -173,7 +173,7 @@ int audio_initOpenCloseQuitAudio()
                 desired.format = AUDIO_S16SYS;
                 desired.channels = 2;
                 desired.samples = 4096;
-                desired.callback = _audio_testCallback;
+                desired.callback = audio_testCallback;
                 desired.userdata = NULL;
 
             case 1:
@@ -182,7 +182,7 @@ int audio_initOpenCloseQuitAudio()
                 desired.format = AUDIO_F32SYS;
                 desired.channels = 2;
                 desired.samples = 2048;
-                desired.callback = _audio_testCallback;
+                desired.callback = audio_testCallback;
                 desired.userdata = NULL;
                 break;
             }
@@ -211,7 +211,7 @@ int audio_initOpenCloseQuitAudio()
     }     /* driver loop */
 
     /* Restart audio again */
-    _audioSetUp(NULL);
+    audioSetUp(NULL);
 
     return TEST_COMPLETED;
 }
@@ -263,7 +263,7 @@ int audio_pauseUnpauseAudio()
                 desired.format = AUDIO_S16SYS;
                 desired.channels = 2;
                 desired.samples = 4096;
-                desired.callback = _audio_testCallback;
+                desired.callback = audio_testCallback;
                 desired.userdata = NULL;
 
             case 1:
@@ -272,7 +272,7 @@ int audio_pauseUnpauseAudio()
                 desired.format = AUDIO_F32SYS;
                 desired.channels = 2;
                 desired.samples = 2048;
-                desired.callback = _audio_testCallback;
+                desired.callback = audio_testCallback;
                 desired.userdata = NULL;
                 break;
             }
@@ -287,8 +287,8 @@ int audio_pauseUnpauseAudio()
                 SDLTest_Log("Pause/Unpause iteration: %d", l + 1);
 
                 /* Reset callback counters */
-                _audio_testCallbackCounter = 0;
-                _audio_testCallbackLength = 0;
+                g_audio_testCallbackCounter = 0;
+                g_audio_testCallbackLength = 0;
 
                 /* Un-pause audio to start playing (maybe multiple times) */
                 pause_on = 0;
@@ -302,9 +302,9 @@ int audio_pauseUnpauseAudio()
                 do {
                     SDL_Delay(10);
                     totalDelay += 10;
-                } while (_audio_testCallbackCounter == 0 && totalDelay < 1000);
-                SDLTest_AssertCheck(_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", _audio_testCallbackCounter);
-                SDLTest_AssertCheck(_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", _audio_testCallbackLength);
+                } while (g_audio_testCallbackCounter == 0 && totalDelay < 1000);
+                SDLTest_AssertCheck(g_audio_testCallbackCounter > 0, "Verify callback counter; expected: >0 got: %d", g_audio_testCallbackCounter);
+                SDLTest_AssertCheck(g_audio_testCallbackLength > 0, "Verify callback length; expected: >0 got: %d", g_audio_testCallbackLength);
 
                 /* Pause audio to stop playing (maybe multiple times) */
                 for (k = 0; k <= j; k++) {
@@ -314,9 +314,9 @@ int audio_pauseUnpauseAudio()
                 }
 
                 /* Ensure callback is not called again */
-                originalCounter = _audio_testCallbackCounter;
+                originalCounter = g_audio_testCallbackCounter;
                 SDL_Delay(totalDelay + 10);
-                SDLTest_AssertCheck(originalCounter == _audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, _audio_testCallbackCounter);
+                SDLTest_AssertCheck(originalCounter == g_audio_testCallbackCounter, "Verify callback counter; expected: %d, got: %d", originalCounter, g_audio_testCallbackCounter);
             }
 
             /* Call Close */
@@ -331,7 +331,7 @@ int audio_pauseUnpauseAudio()
     }     /* driver loop */
 
     /* Restart audio again */
-    _audioSetUp(NULL);
+    audioSetUp(NULL);
 
     return TEST_COMPLETED;
 }
@@ -490,17 +490,17 @@ int audio_printCurrentAudioDriver()
 }
 
 /* Definition of all formats, channels, and frequencies used to test audio conversions */
-const int _numAudioFormats = 18;
-SDL_AudioFormat _audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB,
+const int g_numAudioFormats = 18;
+static SDL_AudioFormat g_audioFormats[] = { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S16SYS, AUDIO_S16, AUDIO_U16LSB,
                                     AUDIO_U16MSB, AUDIO_U16SYS, AUDIO_U16, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S32SYS, AUDIO_S32,
                                     AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_F32SYS, AUDIO_F32 };
-const char *_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
+const char *g_audioFormatsVerbose[] = { "AUDIO_S8", "AUDIO_U8", "AUDIO_S16LSB", "AUDIO_S16MSB", "AUDIO_S16SYS", "AUDIO_S16", "AUDIO_U16LSB",
                                        "AUDIO_U16MSB", "AUDIO_U16SYS", "AUDIO_U16", "AUDIO_S32LSB", "AUDIO_S32MSB", "AUDIO_S32SYS", "AUDIO_S32",
                                        "AUDIO_F32LSB", "AUDIO_F32MSB", "AUDIO_F32SYS", "AUDIO_F32" };
-const int _numAudioChannels = 4;
-Uint8 _audioChannels[] = { 1, 2, 4, 6 };
-const int _numAudioFrequencies = 4;
-int _audioFrequencies[] = { 11025, 22050, 44100, 48000 };
+const int g_numAudioChannels = 4;
+Uint8 g_audioChannels[] = { 1, 2, 4, 6 };
+const int g_numAudioFrequencies = 4;
+int g_audioFrequencies[] = { 11025, 22050, 44100, 48000 };
 
 /**
  * \brief Builds various audio conversion structures
@@ -537,22 +537,22 @@ int audio_buildAudioCVT()
     SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
 
     /* All source conversions with random conversion targets, allow 'null' conversions */
-    for (i = 0; i < _numAudioFormats; i++) {
-        for (j = 0; j < _numAudioChannels; j++) {
-            for (k = 0; k < _numAudioFrequencies; k++) {
-                spec1.format = _audioFormats[i];
-                spec1.channels = _audioChannels[j];
-                spec1.freq = _audioFrequencies[k];
-                ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
-                jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
-                kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
-                spec2.format = _audioFormats[ii];
-                spec2.channels = _audioChannels[jj];
-                spec2.freq = _audioFrequencies[kk];
+    for (i = 0; i < g_numAudioFormats; i++) {
+        for (j = 0; j < g_numAudioChannels; j++) {
+            for (k = 0; k < g_numAudioFrequencies; k++) {
+                spec1.format = g_audioFormats[i];
+                spec1.channels = g_audioChannels[j];
+                spec1.freq = g_audioFrequencies[k];
+                ii = SDLTest_RandomIntegerInRange(0, g_numAudioFormats - 1);
+                jj = SDLTest_RandomIntegerInRange(0, g_numAudioChannels - 1);
+                kk = SDLTest_RandomIntegerInRange(0, g_numAudioFrequencies - 1);
+                spec2.format = g_audioFormats[ii];
+                spec2.channels = g_audioChannels[jj];
+                spec2.freq = g_audioFrequencies[kk];
                 result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
                                            spec2.format, spec2.channels, spec2.freq);
                 SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
-                                   i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
+                                   i, g_audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, g_audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
                 SDLTest_AssertCheck(result == 0 || result == 1, "Verify result value; expected: 0 or 1, got: %i", result);
                 if (result < 0) {
                     SDLTest_LogError("%s", SDL_GetError());
@@ -712,7 +712,7 @@ int audio_openCloseAndGetAudioStatus()
             desired.format = AUDIO_S16SYS;
             desired.channels = 2;
             desired.samples = 4096;
-            desired.callback = _audio_testCallback;
+            desired.callback = audio_testCallback;
             desired.userdata = NULL;
 
             /* Open device */
@@ -772,7 +772,7 @@ int audio_lockUnlockOpenAudioDevice()
             desired.format = AUDIO_S16SYS;
             desired.channels = 2;
             desired.samples = 4096;
-            desired.callback = _audio_testCallback;
+            desired.callback = audio_testCallback;
             desired.userdata = NULL;
 
             /* Open device */
@@ -834,39 +834,39 @@ int audio_convertAudio()
         }
         SDLTest_Log("%s", message);
         /* All source conversions with random conversion targets */
-        for (i = 0; i < _numAudioFormats; i++) {
-            for (j = 0; j < _numAudioChannels; j++) {
-                for (k = 0; k < _numAudioFrequencies; k++) {
-                    spec1.format = _audioFormats[i];
-                    spec1.channels = _audioChannels[j];
-                    spec1.freq = _audioFrequencies[k];
+        for (i = 0; i < g_numAudioFormats; i++) {
+            for (j = 0; j < g_numAudioChannels; j++) {
+                for (k = 0; k < g_numAudioFrequencies; k++) {
+                    spec1.format = g_audioFormats[i];
+                    spec1.channels = g_audioChannels[j];
+                    spec1.freq = g_audioFrequencies[k];
 
                     /* Ensure we have a different target format */
                     do {
                         if (c & 1) {
-                            ii = SDLTest_RandomIntegerInRange(0, _numAudioFormats - 1);
+                            ii = SDLTest_RandomIntegerInRange(0, g_numAudioFormats - 1);
                         } else {
                             ii = 1;
                         }
                         if (c & 2) {
-                            jj = SDLTest_RandomIntegerInRange(0, _numAudioChannels - 1);
+                            jj = SDLTest_RandomIntegerInRange(0, g_numAudioChannels - 1);
                         } else {
                             jj = j;
                         }
                         if (c & 4) {
-                            kk = SDLTest_RandomIntegerInRange(0, _numAudioFrequencies - 1);
+                            kk = SDLTest_RandomIntegerInRange(0, g_numAudioFrequencies - 1);
                         } else {
                             kk = k;
                         }
                     } while ((i == ii) && (j == jj) && (k == kk));
-                    spec2.format = _audioFormats[ii];
-                    spec2.channels = _audioChannels[jj];
-                    spec2.freq = _audioFrequencies[kk];
+                    spec2.format = g_audioFormats[ii];
+                    spec2.channels = g_audioChannels[jj];
+                    spec2.freq = g_audioFrequencies[kk];
 
                     result = SDL_BuildAudioCVT(&cvt, spec1.format, spec1.channels, spec1.freq,
                                                spec2.format, spec2.channels, spec2.freq);
                     SDLTest_AssertPass("Call to SDL_BuildAudioCVT(format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i ==> format[%i]=%s(%i),channels[%i]=%i,freq[%i]=%i)",
-                                       i, _audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, _audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
+                                       i, g_audioFormatsVerbose[i], spec1.format, j, spec1.channels, k, spec1.freq, ii, g_audioFormatsVerbose[ii], spec2.format, jj, spec2.channels, kk, spec2.freq);
                     SDLTest_AssertCheck(result == 1, "Verify result value; expected: 1, got: %i", result);
                     if (result != 1) {
                         SDLTest_LogError("%s", SDL_GetError());
@@ -938,7 +938,7 @@ int audio_openCloseAudioDeviceConnected()
             desired.format = AUDIO_S16SYS;
             desired.channels = 2;
             desired.samples = 4096;
-            desired.callback = _audio_testCallback;
+            desired.callback = audio_testCallback;
             desired.userdata = NULL;
 
             /* Open device */
@@ -1046,7 +1046,7 @@ static const SDLTest_TestCaseReference *audioTests[] = {
 /* Audio test suite (global) */
 SDLTest_TestSuiteReference audioTestSuite = {
     "Audio",
-    _audioSetUp,
+    audioSetUp,
     audioTests,
-    _audioTearDown
+    audioTearDown
 };
diff --git a/test/testautomation_events.c b/test/testautomation_events.c
index 11ad51164b21..8b11f799f961 100644
--- a/test/testautomation_events.c
+++ b/test/testautomation_events.c
@@ -9,27 +9,27 @@
 /* Test case functions */
 
 /* Flag indicating if the userdata should be checked */
-int _userdataCheck = 0;
+static int g_userdataCheck = 0;
 
 /* Userdata value to check */
-int _userdataValue = 0;
+static int g_userdataValue = 0;
 
 /* Flag indicating that the filter was called */
-int _eventFilterCalled = 0;
+static int g_eventFilterCalled = 0;
 
 /* Userdata values for event */
-int _userdataValue1 = 1;
-int _userdataValue2 = 2;
+static int g_userdataValue1 = 1;
+static int g_userdataValue2 = 2;
 
 /* Event filter that sets some flags and optionally checks userdata */
-int SDLCALL _events_sampleNullEventFilter(void *userdata, SDL_Event *event)
+static int SDLCALL events_sampleNullEventFilter(void *userdata, SDL_Event *event)
 {
-    _eventFilterCalled = 1;
+    g_eventFilterCalled = 1;
 
-    if (_userdataCheck != 0) {
+    if (g_userdataCheck != 0) {
         SDLTest_AssertCheck(userdata != NULL, "Check userdata pointer, expected: non-NULL, got: %s", (userdata != NULL) ? "non-NULL" : "NULL");
         if (userdata != NULL) {
-            SDLTest_AssertCh

(Patch may be truncated, please check the link at the top of this post.)