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

@@ -270,7 +270,7 @@ QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char** device_name)
{
DIPROPSTRING dipstr;
if (!device || !device_name) {
if (!device || device_name == NULL) {
return SDL_FALSE;
}
@@ -293,7 +293,7 @@ QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char** device_path)
{
DIPROPGUIDANDPATH dippath;
if (!device || !device_path) {
if (!device || device_path == NULL) {
return SDL_FALSE;
}
@@ -319,7 +319,7 @@ QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16* vendor_id, Uint16* product_
{
DIPROPDWORD dipdw;
if (!device || !vendor_id || !product_id) {
if (!device || vendor_id == NULL || product_id == NULL) {
return SDL_FALSE;
}
@@ -341,7 +341,7 @@ QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16* vendor_id, Uint16* product_
void FreeRumbleEffectData(DIEFFECT *effect)
{
if (!effect) {
if (effect == NULL) {
return;
}
SDL_free(effect->rgdwAxes);
@@ -357,7 +357,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude)
/* Create the effect */
effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect));
if (!effect) {
if (effect == NULL) {
return NULL;
}
effect->dwSize = sizeof(*effect);
@@ -381,7 +381,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude)
effect->dwFlags |= DIEFF_CARTESIAN;
periodic = (DIPERIODIC *)SDL_calloc(1, sizeof(*periodic));
if (!periodic) {
if (periodic == NULL) {
FreeRumbleEffectData(effect);
return NULL;
}
@@ -441,7 +441,7 @@ SDL_DINPUT_JoystickInit(void)
static BOOL CALLBACK
EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext)
{
#define CHECK(expression) { if(!(expression)) goto err; }
#define CHECK(expression) { if (!(expression)) goto err; }
JoyStick_DeviceData *pNewJoystick = NULL;
JoyStick_DeviceData *pPrevJoystick = NULL;
Uint16 vendor = 0;
@@ -468,8 +468,7 @@ EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext)
/* if we are replacing the front of the list then update it */
if (pNewJoystick == *(JoyStick_DeviceData**)pContext) {
*(JoyStick_DeviceData**)pContext = pNewJoystick->pNext;
}
else if (pPrevJoystick) {
} else if (pPrevJoystick) {
pPrevJoystick->pNext = pNewJoystick->pNext;
}
@@ -554,7 +553,7 @@ typedef struct
static BOOL CALLBACK
EnumJoystickPresentCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext)
{
#define CHECK(expression) { if(!(expression)) goto err; }
#define CHECK(expression) { if (!(expression)) goto err; }
Joystick_PresentData *pData = (Joystick_PresentData *)pContext;
Uint16 vendor = 0;
Uint16 product = 0;
@@ -690,10 +689,12 @@ SortDevFunc(const void *a, const void *b)
const input_t *inputA = (const input_t*)a;
const input_t *inputB = (const input_t*)b;
if (inputA->ofs < inputB->ofs)
if (inputA->ofs < inputB->ofs) {
return -1;
if (inputA->ofs > inputB->ofs)
}
if (inputA->ofs > inputB->ofs) {
return 1;
}
return 0;
}
@@ -965,16 +966,18 @@ TranslatePOV(DWORD value)
SDL_HAT_UP | SDL_HAT_LEFT
};
if (LOWORD(value) == 0xFFFF)
if (LOWORD(value) == 0xFFFF) {
return SDL_HAT_CENTERED;
}
/* Round the value up: */
value += 4500 / 2;
value %= 36000;
value /= 4500;
if (value >= 8)
return SDL_HAT_CENTERED; /* shouldn't happen */
if (value >= 8) {
return SDL_HAT_CENTERED; /* shouldn't happen */
}
return HAT_VALS[value];
}
@@ -1085,8 +1088,9 @@ UpdateDINPUTJoystickState_Buffered(SDL_Joystick * joystick)
for (j = 0; j < joystick->hwdata->NumInputs; ++j) {
const input_t *in = &joystick->hwdata->Inputs[j];
if (evtbuf[i].dwOfs != in->ofs)
if (evtbuf[i].dwOfs != in->ofs) {
continue;
}
switch (in->type) {
case AXIS: