From b057254fd4da23b923996fe81276ff3591437029 Mon Sep 17 00:00:00 2001 From: "J?rgen P. Tjern?" Date: Mon, 25 Feb 2013 16:52:54 -0800 Subject: [PATCH] Cleanup of SDL_PrivateShouldInitSubsystem. Also fixes a build error if a module was disabled. --- src/SDL.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/SDL.c b/src/SDL.c index 53e0e7449..ae279860d 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -68,14 +68,9 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem) /* 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 @@ SDL_InitSubSystem(Uint32 flags) /* 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 @@ SDL_InitSubSystem(Uint32 flags) /* 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 @@ SDL_InitSubSystem(Uint32 flags) /* 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 @@ SDL_InitSubSystem(Uint32 flags) /* 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 @@ SDL_InitSubSystem(Uint32 flags) } 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 @@ SDL_InitSubSystem(Uint32 flags) /* 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 @@ _DllMainCRTStartup(HANDLE hModule, #endif /* __WIN32__ */ -/* vi: set ts=4 sw=4 expandtab: */ +/* vi: set sts=4 ts=4 sw=4 expandtab: */