Cleanup add brace (#6545)

* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
This commit is contained in:
Sylvain Becker
2022-11-27 17:38:43 +01:00
committed by GitHub
parent 4958dafdc3
commit 6a2200823c
387 changed files with 6094 additions and 4633 deletions

View File

@@ -60,8 +60,7 @@ ValidHaptic(SDL_Haptic * haptic)
valid = 0;
if (haptic != NULL) {
hapticlist = SDL_haptics;
while ( hapticlist )
{
while ( hapticlist ) {
if (hapticlist == haptic) {
valid = 1;
break;
@@ -123,8 +122,7 @@ SDL_HapticOpen(int device_index)
/* If the haptic is already open, return it
* TODO: Should we create haptic instance IDs like the Joystick API?
*/
while ( hapticlist )
{
while ( hapticlist ) {
if (device_index == hapticlist->index) {
haptic = hapticlist;
++haptic->ref_count;
@@ -156,10 +154,12 @@ SDL_HapticOpen(int device_index)
SDL_haptics = haptic;
/* Disable autocenter and set gain to max. */
if (haptic->supported & SDL_HAPTIC_GAIN)
if (haptic->supported & SDL_HAPTIC_GAIN) {
SDL_HapticSetGain(haptic, 100);
if (haptic->supported & SDL_HAPTIC_AUTOCENTER)
}
if (haptic->supported & SDL_HAPTIC_AUTOCENTER) {
SDL_HapticSetAutocenter(haptic, 0);
}
return haptic;
}
@@ -184,8 +184,7 @@ SDL_HapticOpened(int device_index)
opened = 0;
hapticlist = SDL_haptics;
/* TODO Should this use an instance ID? */
while ( hapticlist )
{
while ( hapticlist ) {
if (hapticlist->index == (Uint8) device_index) {
opened = 1;
break;
@@ -216,8 +215,9 @@ SDL_HapticIndex(SDL_Haptic * haptic)
int
SDL_MouseIsHaptic(void)
{
if (SDL_SYS_HapticMouse() < 0)
if (SDL_SYS_HapticMouse() < 0) {
return SDL_FALSE;
}
return SDL_TRUE;
}
@@ -295,8 +295,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick)
hapticlist = SDL_haptics;
/* Check to see if joystick's haptic is already open */
while ( hapticlist )
{
while ( hapticlist ) {
if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) {
haptic = hapticlist;
++haptic->ref_count;
@@ -362,17 +361,12 @@ SDL_HapticClose(SDL_Haptic * haptic)
/* Remove from the list */
hapticlist = SDL_haptics;
hapticlistprev = NULL;
while ( hapticlist )
{
if (haptic == hapticlist)
{
if ( hapticlistprev )
{
while ( hapticlist ) {
if (haptic == hapticlist) {
if ( hapticlistprev ) {
/* unlink this entry */
hapticlistprev->next = hapticlist->next;
}
else
{
} else {
SDL_haptics = haptic->next;
}
@@ -464,8 +458,9 @@ SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect)
return -1;
}
if ((haptic->supported & effect->type) != 0)
if ((haptic->supported & effect->type) != 0) {
return SDL_TRUE;
}
return SDL_FALSE;
}
@@ -646,10 +641,11 @@ SDL_HapticSetGain(SDL_Haptic * haptic, int gain)
max_gain = SDL_atoi(env);
/* Check for sanity. */
if (max_gain < 0)
if (max_gain < 0) {
max_gain = 0;
else if (max_gain > 100)
} else if (max_gain > 100) {
max_gain = 100;
}
/* We'll scale it linearly with SDL_HAPTIC_GAIN_MAX */
real_gain = (gain * max_gain) / 100;
@@ -747,7 +743,7 @@ SDL_HapticRumbleSupported(SDL_Haptic * haptic)
}
/* Most things can use SINE, but XInput only has LEFTRIGHT. */
return ((haptic->supported & (SDL_HAPTIC_SINE|SDL_HAPTIC_LEFTRIGHT)) != 0);
return (haptic->supported & (SDL_HAPTIC_SINE | SDL_HAPTIC_LEFTRIGHT)) != 0;
}
/*

View File

@@ -54,13 +54,13 @@ SDL_SYS_HapticInit(void)
timeout = SDL_GetTicks() + 3000;
Android_JNI_PollHapticDevices();
}
return (numhaptics);
return numhaptics;
}
int
SDL_SYS_NumHaptics(void)
{
return (numhaptics);
return numhaptics;
}
static SDL_hapticlist_item *
@@ -133,19 +133,19 @@ OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item)
static SDL_hapticlist_item *
OpenHapticByOrder(SDL_Haptic *haptic, int index)
{
return OpenHaptic (haptic, HapticByOrder(index));
return OpenHaptic(haptic, HapticByOrder(index));
}
static SDL_hapticlist_item *
OpenHapticByDevId(SDL_Haptic *haptic, int device_id)
{
return OpenHaptic (haptic, HapticByDevId(device_id));
return OpenHaptic(haptic, HapticByDevId(device_id));
}
int
SDL_SYS_HapticOpen(SDL_Haptic *haptic)
{
return (OpenHapticByOrder(haptic, haptic->index) == NULL ? -1 : 0);
return OpenHapticByOrder(haptic, haptic->index) == NULL ? -1 : 0;
}
@@ -168,14 +168,14 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
{
return (OpenHapticByDevId(haptic, ((joystick_hwdata *)joystick->hwdata)->device_id) == NULL ? -1 : 0);
return OpenHapticByDevId(haptic, ((joystick_hwdata *)joystick->hwdata)->device_id) == NULL ? -1 : 0;
}
int
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
return (((SDL_hapticlist_item *)haptic->hwdata)->device_id == ((joystick_hwdata *)joystick->hwdata)->device_id ? 1 : 0);
return ((SDL_hapticlist_item *)haptic->hwdata)->device_id == ((joystick_hwdata *)joystick->hwdata)->device_id ? 1 : 0;
}

View File

@@ -226,8 +226,7 @@ MacHaptic_MaybeAddDevice( io_object_t device )
}
/* Make sure we don't already have it */
for (item = SDL_hapticlist; item ; item = item->next)
{
for (item = SDL_hapticlist; item ; item = item->next) {
if (IOObjectIsEqualTo((io_object_t) item->dev, device)) {
/* Already added */
return -1;

View File

@@ -78,8 +78,10 @@ static SDL_hapticlist_item *SDL_hapticlist = NULL;
static SDL_hapticlist_item *SDL_hapticlist_tail = NULL;
static int numhaptics = 0;
#define EV_TEST(ev,f) \
if (test_bit((ev), features)) ret |= (f);
#define EV_TEST(ev,f) \
if (test_bit((ev), features)) { \
ret |= (f); \
}
/*
* Test whether a device has haptic properties.
* Returns available properties or 0 if there are none.
@@ -753,8 +755,9 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
/* Header */
dest->type = FF_CONSTANT;
if (SDL_SYS_ToDirection(&dest->direction, &constant->direction) == -1)
if (SDL_SYS_ToDirection(&dest->direction, &constant->direction) == -1) {
return -1;
}
/* Replay */
dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ?
@@ -788,8 +791,9 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
/* Header */
dest->type = FF_PERIODIC;
if (SDL_SYS_ToDirection(&dest->direction, &periodic->direction) == -1)
if (SDL_SYS_ToDirection(&dest->direction, &periodic->direction) == -1) {
return -1;
}
/* Replay */
dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ?
@@ -801,17 +805,18 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
dest->trigger.interval = CLAMP(periodic->interval);
/* Periodic */
if (periodic->type == SDL_HAPTIC_SINE)
if (periodic->type == SDL_HAPTIC_SINE) {
dest->u.periodic.waveform = FF_SINE;
/* !!! FIXME: put this back when we have more bits in 2.1 */
/* else if (periodic->type == SDL_HAPTIC_SQUARE)
dest->u.periodic.waveform = FF_SQUARE; */
else if (periodic->type == SDL_HAPTIC_TRIANGLE)
} else if (periodic->type == SDL_HAPTIC_TRIANGLE) {
dest->u.periodic.waveform = FF_TRIANGLE;
else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP)
} else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) {
dest->u.periodic.waveform = FF_SAW_UP;
else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN)
} else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN) {
dest->u.periodic.waveform = FF_SAW_DOWN;
}
dest->u.periodic.period = CLAMP(periodic->period);
dest->u.periodic.magnitude = periodic->magnitude;
dest->u.periodic.offset = periodic->offset;
@@ -835,14 +840,16 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
condition = &src->condition;
/* Header */
if (condition->type == SDL_HAPTIC_SPRING)
if (condition->type == SDL_HAPTIC_SPRING) {
dest->type = FF_SPRING;
else if (condition->type == SDL_HAPTIC_DAMPER)
} else if (condition->type == SDL_HAPTIC_DAMPER) {
dest->type = FF_DAMPER;
else if (condition->type == SDL_HAPTIC_INERTIA)
} else if (condition->type == SDL_HAPTIC_INERTIA) {
dest->type = FF_INERTIA;
else if (condition->type == SDL_HAPTIC_FRICTION)
} else if (condition->type == SDL_HAPTIC_FRICTION) {
dest->type = FF_FRICTION;
}
dest->direction = 0; /* Handled by the condition-specifics. */
/* Replay */
@@ -881,8 +888,9 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src)
/* Header */
dest->type = FF_RAMP;
if (SDL_SYS_ToDirection(&dest->direction, &ramp->direction) == -1)
if (SDL_SYS_ToDirection(&dest->direction, &ramp->direction) == -1) {
return -1;
}
/* Replay */
dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ?

View File

@@ -569,18 +569,22 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
case SDL_HAPTIC_CARTESIAN:
effect->dwFlags |= DIEFF_CARTESIAN;
rglDir[0] = dir->dir[0];
if (naxes > 1)
if (naxes > 1) {
rglDir[1] = dir->dir[1];
if (naxes > 2)
}
if (naxes > 2) {
rglDir[2] = dir->dir[2];
}
return 0;
case SDL_HAPTIC_SPHERICAL:
effect->dwFlags |= DIEFF_SPHERICAL;
rglDir[0] = dir->dir[0];
if (naxes > 1)
if (naxes > 1) {
rglDir[1] = dir->dir[1];
if (naxes > 2)
}
if (naxes > 2) {
rglDir[2] = dir->dir[2];
}
return 0;
case SDL_HAPTIC_STEERING_AXIS:
effect->dwFlags |= DIEFF_CARTESIAN;
@@ -1092,8 +1096,9 @@ SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effe
return DI_SetError("Getting effect status", ret);
}
if (status == 0)
if (status == 0) {
return SDL_FALSE;
}
return SDL_TRUE;
}

View File

@@ -228,7 +228,7 @@ SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item)
int
SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
return (haptic->hwdata->userid == joystick->hwdata->userid);
return haptic->hwdata->userid == joystick->hwdata->userid;
}
int