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

(cherry picked from commit 6a2200823c to reduce conflicts merging between SDL2 and SDL3)
This commit is contained in:
Sylvain Becker
2022-11-27 17:38:43 +01:00
committed by Sam Lantinga
parent 0739d237ad
commit fb0ce375f0
386 changed files with 6103 additions and 4637 deletions

View File

@@ -22,7 +22,7 @@
#include "SDL_test_common.h"
#define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while(0)
#define SWAP(typ,a,b) do{typ t=a;a=b;b=t;}while (0)
#define NUM_OBJECTS 100
static SDLTest_CommonState *state;
@@ -86,10 +86,12 @@ SDL_Rect lines[MAX_LINES];
static int
add_line(int x1, int y1, int x2, int y2)
{
if (num_lines >= MAX_LINES)
if (num_lines >= MAX_LINES) {
return 0;
if ((x1 == x2) && (y1 == y2))
}
if ((x1 == x2) && (y1 == y2)) {
return 0;
}
SDL_Log("adding line (%d, %d), (%d, %d)\n", x1, y1, x2, y2);
lines[num_lines].x = x1;
@@ -130,15 +132,19 @@ SDL_Rect rects[MAX_RECTS];
static int
add_rect(int x1, int y1, int x2, int y2)
{
if (num_rects >= MAX_RECTS)
if (num_rects >= MAX_RECTS) {
return 0;
if ((x1 == x2) || (y1 == y2))
}
if ((x1 == x2) || (y1 == y2)) {
return 0;
}
if (x1 > x2)
if (x1 > x2) {
SWAP(int, x1, x2);
if (y1 > y2)
}
if (y1 > y2) {
SWAP(int, y1, y2);
}
SDL_Log("adding rect (%d, %d), (%d, %d) [%dx%d]\n", x1, y1, x2, y2,
x2 - x1, y2 - y1);
@@ -213,12 +219,12 @@ loop()
mouse_begin_y = event.button.y;
break;
case SDL_MOUSEBUTTONUP:
if (event.button.button == 3)
add_line(mouse_begin_x, mouse_begin_y, event.button.x,
event.button.y);
if (event.button.button == 1)
add_rect(mouse_begin_x, mouse_begin_y, event.button.x,
event.button.y);
if (event.button.button == 3) {
add_line(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
}
if (event.button.button == 1) {
add_rect(mouse_begin_x, mouse_begin_y, event.button.x, event.button.y);
}
break;
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
@@ -244,8 +250,9 @@ loop()
}
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
if (state->windows[i] == NULL)
if (state->windows[i] == NULL) {
continue;
}
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
SDL_RenderClear(renderer);
@@ -278,7 +285,7 @@ main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (!state) {
if (state == NULL) {
return 1;
}
for (i = 1; i < argc;) {