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

@@ -46,8 +46,7 @@ readSymLink(const char *path)
ssize_t len = 64;
ssize_t rc = -1;
while (1)
{
while (1) {
char *ptr = (char *) SDL_realloc(retval, (size_t) len);
if (ptr == NULL) {
SDL_OutOfMemory();
@@ -80,13 +79,13 @@ static char *search_path_for_binary(const char *bin)
char *start = envr;
char *ptr;
if (!envr) {
if (envr == NULL) {
SDL_SetError("No $PATH set");
return NULL;
}
envr = SDL_strdup(envr);
if (!envr) {
if (envr == NULL) {
SDL_OutOfMemory();
return NULL;
}
@@ -135,7 +134,7 @@ SDL_GetBasePath(void)
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) {
retval = SDL_strdup(fullpath);
if (!retval) {
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
}
@@ -149,13 +148,13 @@ SDL_GetBasePath(void)
if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) {
char *exe, *pwddst;
char *realpathbuf = (char *) SDL_malloc(PATH_MAX + 1);
if (!realpathbuf) {
if (realpathbuf == NULL) {
SDL_OutOfMemory();
return NULL;
}
cmdline = SDL_malloc(len);
if (!cmdline) {
if (cmdline == NULL) {
SDL_free(realpathbuf);
SDL_OutOfMemory();
return NULL;
@@ -193,7 +192,7 @@ SDL_GetBasePath(void)
}
}
if (!retval) {
if (retval == NULL) {
SDL_free(realpathbuf);
}
@@ -204,7 +203,7 @@ SDL_GetBasePath(void)
const char *path = getexecname();
if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */
retval = SDL_strdup(path);
if (!retval) {
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
}
@@ -212,7 +211,7 @@ SDL_GetBasePath(void)
#endif
/* is a Linux-style /proc filesystem available? */
if (!retval && (access("/proc", F_OK) == 0)) {
if (retval == NULL && (access("/proc", F_OK) == 0)) {
/* !!! FIXME: after 2.0.6 ships, let's delete this code and just
use the /proc/%llu version. There's no reason to have
two copies of this plus all the #ifdefs. --ryan. */
@@ -251,8 +250,9 @@ SDL_GetBasePath(void)
if (retval != NULL) {
/* try to shrink buffer... */
char *ptr = (char *) SDL_realloc(retval, SDL_strlen(retval) + 1);
if (ptr != NULL)
retval = ptr; /* oh well if it failed. */
if (ptr != NULL) {
retval = ptr; /* oh well if it failed. */
}
}
return retval;
@@ -274,18 +274,18 @@ SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (!app) {
if (app == NULL) {
SDL_InvalidParamError("app");
return NULL;
}
if (!org) {
if (org == NULL) {
org = "";
}
if (!envr) {
if (envr == NULL) {
/* You end up with "$HOME/.local/share/Game Name 2" */
envr = SDL_getenv("HOME");
if (!envr) {
if (envr == NULL) {
/* we could take heroic measures with /etc/passwd, but oh well. */
SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
return NULL;
@@ -296,12 +296,13 @@ SDL_GetPrefPath(const char *org, const char *app)
}
len = SDL_strlen(envr);
if (envr[len - 1] == '/')
if (envr[len - 1] == '/') {
append += 1;
}
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *) SDL_malloc(len);
if (!retval) {
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
}
@@ -315,8 +316,9 @@ SDL_GetPrefPath(const char *org, const char *app)
for (ptr = retval+1; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';
if (mkdir(retval, 0700) != 0 && errno != EEXIST)
if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
goto error;
}
*ptr = '/';
}
}