Cleanup of SDL_PrivateShouldInitSubsystem.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Mon, 25 Feb 2013 16:52:54 -0800
changeset 6927 982b03203b73
parent 6926 166712f45009
child 6928 0195a2cc093c
Cleanup of SDL_PrivateShouldInitSubsystem. Also fixes a build error if a module was disabled.
src/SDL.c
--- a/src/SDL.c	Mon Feb 25 16:52:52 2013 -0800
+++ b/src/SDL.c	Mon Feb 25 16:52:54 2013 -0800
@@ -68,14 +68,9 @@
 
 /* Private helper to check if a system needs init. */
 static SDL_bool
-SDL_PrivateShouldInitSubsystem(Uint32 flags, Uint32 subsystem)
+SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
 {
-    int subsystem_index;
-    if ((flags & subsystem) == 0) {
-      return SDL_FALSE;
-    }
-
-    subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
+    int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
     SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
     return (SDL_SubsystemRefCount[subsystem_index] == 0);
 }
@@ -106,8 +101,8 @@
 
     /* Initialize the timer subsystem */
     if ((flags & SDL_INIT_TIMER) ){
-        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_TIMER)) {
 #if !SDL_TIMERS_DISABLED
+        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
             if (SDL_TimerInit() < 0) {
                 return (-1);
             }
@@ -121,8 +116,8 @@
 
     /* Initialize the video/event subsystem */
     if ((flags & SDL_INIT_VIDEO) ){
-        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_VIDEO)) {
 #if !SDL_VIDEO_DISABLED
+        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
             if (SDL_VideoInit(NULL) < 0) {
                 return (-1);
             }
@@ -136,8 +131,8 @@
 
     /* Initialize the audio subsystem */
     if ((flags & SDL_INIT_AUDIO) ){
-        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_AUDIO)) {
 #if !SDL_AUDIO_DISABLED
+        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
             if (SDL_AudioInit(NULL) < 0) {
                 return (-1);
             }
@@ -156,8 +151,8 @@
 
     /* Initialize the joystick subsystem */
     if ((flags & SDL_INIT_JOYSTICK) ){
-        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_JOYSTICK)) {
 #if !SDL_JOYSTICK_DISABLED
+        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
            if (SDL_JoystickInit() < 0) {
                return (-1);
            }
@@ -170,8 +165,8 @@
     }
 
     if ((flags & SDL_INIT_GAMECONTROLLER) ){
-        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_GAMECONTROLLER)) {
 #if !SDL_JOYSTICK_DISABLED
+        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
             if (SDL_GameControllerInit() < 0) {
                 return (-1);
             }
@@ -185,11 +180,11 @@
 
     /* Initialize the haptic subsystem */
     if ((flags & SDL_INIT_HAPTIC) ){
-        if (SDL_PrivateShouldInitSubsystem(flags, SDL_INIT_HAPTIC)) {
 #if !SDL_HAPTIC_DISABLED
+        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
             if (SDL_HapticInit() < 0) {
-             return (-1);
-         }
+                return (-1);
+            }
         }
         SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
 #else
@@ -441,4 +436,4 @@
 
 #endif /* __WIN32__ */
 
-/* vi: set ts=4 sw=4 expandtab: */
+/* vi: set sts=4 ts=4 sw=4 expandtab: */