Code style fixes, etc.

Reference PR #6345.
This commit is contained in:
Ryan C. Gordon
2022-11-16 12:53:48 -05:00
parent ec58a817ef
commit 389ffab733
5 changed files with 32 additions and 24 deletions

View File

@@ -124,18 +124,19 @@ static Uint8 SDL_SubsystemRefCount[ 32 ];
static void
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
{
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
if (subsystem_index >= 0)
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
if (subsystem_index >= 0) {
++SDL_SubsystemRefCount[subsystem_index];
}
}
/* Private helper to decrement a subsystem's ref counter. */
static void
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
{
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] > 0) {
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
--SDL_SubsystemRefCount[subsystem_index];
}
}
@@ -144,23 +145,23 @@ SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(subsystem_index < 0 || SDL_SubsystemRefCount[subsystem_index] < 255);
return (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
return ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) ? SDL_TRUE : SDL_FALSE;
}
/* Private helper to check if a system needs to be quit. */
static SDL_bool
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if (subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 0) {
return SDL_FALSE;
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
return SDL_FALSE;
}
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
* isn't zero.
*/
return ((subsystem_index >= 0 && SDL_SubsystemRefCount[subsystem_index] == 1) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
}
void