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:
@@ -44,7 +44,7 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
if (path) {
|
||||
size_t pathlen = SDL_strlen(path)+2;
|
||||
char *fullpath = (char *)SDL_malloc(pathlen);
|
||||
if (!fullpath) {
|
||||
if (fullpath == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -45,17 +45,17 @@ 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 = "";
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -69,8 +69,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 = '/';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ SDL_GetBasePath(void)
|
||||
|
||||
const size_t len = SDL_strlen(str);
|
||||
char *retval = (char *) SDL_malloc(len + 2);
|
||||
if (!retval) {
|
||||
if (retval == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -74,11 +74,11 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
const char *append = "/config/settings/";
|
||||
size_t len = SDL_strlen(home);
|
||||
|
||||
if (!app) {
|
||||
if (app == NULL) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if (!org) {
|
||||
if (org == NULL) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
}
|
||||
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
char *retval = (char *) SDL_malloc(len);
|
||||
if (!retval) {
|
||||
if (retval == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
} else {
|
||||
if (*org) {
|
||||
|
||||
@@ -39,8 +39,9 @@ SDL_GetBasePath(void)
|
||||
getcwd(cwd, sizeof(cwd));
|
||||
len = SDL_strlen(cwd) + 1;
|
||||
retval = (char *) SDL_malloc(len);
|
||||
if (retval)
|
||||
if (retval) {
|
||||
SDL_memcpy(retval, cwd, len);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -54,15 +55,17 @@ static void recursive_mkdir(const char *dir) {
|
||||
|
||||
snprintf(tmp, sizeof(tmp),"%s",dir);
|
||||
len = strlen(tmp);
|
||||
if (tmp[len - 1] == '/')
|
||||
if (tmp[len - 1] == '/') {
|
||||
tmp[len - 1] = 0;
|
||||
}
|
||||
|
||||
for (p = tmp + 1; *p; p++) {
|
||||
if (*p == '/') {
|
||||
*p = 0;
|
||||
// Just creating subfolders from current path
|
||||
if (strstr(tmp, base) != NULL)
|
||||
if (strstr(tmp, base) != NULL) {
|
||||
mkdir(tmp, S_IRWXU);
|
||||
}
|
||||
|
||||
*p = '/';
|
||||
}
|
||||
@@ -78,11 +81,11 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
char *retval = NULL;
|
||||
size_t len;
|
||||
char *base = SDL_GetBasePath();
|
||||
if (!app) {
|
||||
if (app == NULL) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if(!org) {
|
||||
if (org == NULL) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,11 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
char *retval = NULL;
|
||||
size_t len;
|
||||
char *base = SDL_GetBasePath();
|
||||
if (!app) {
|
||||
if (app == NULL) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if(!org) {
|
||||
if (org == NULL) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -36,22 +36,23 @@ SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, int filetype)
|
||||
{
|
||||
const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */
|
||||
|
||||
if (!buffer) {
|
||||
if (buffer == NULL) {
|
||||
/* This matches the logic in __unixify, with an additional byte for the
|
||||
* extra path separator.
|
||||
*/
|
||||
buf_len = SDL_strlen(ro_path) + 14 + 1;
|
||||
buffer = SDL_malloc(buf_len);
|
||||
|
||||
if (!buffer) {
|
||||
if (buffer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!__unixify_std(ro_path, buffer, buf_len, filetype)) {
|
||||
if (!in_buf)
|
||||
if (in_buf == NULL) {
|
||||
SDL_free(buffer);
|
||||
}
|
||||
|
||||
SDL_SetError("Could not convert '%s' to a Unix-style path", ro_path);
|
||||
return NULL;
|
||||
@@ -90,7 +91,7 @@ canonicalisePath(const char *path, const char *pathVar)
|
||||
|
||||
regs.r[5] = 1 - regs.r[5];
|
||||
buf = SDL_malloc(regs.r[5]);
|
||||
if (!buf) {
|
||||
if (buf == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -120,8 +121,9 @@ createDirectoryRecursive(char *path)
|
||||
*ptr = '\0';
|
||||
error = _kernel_swi(OS_File, ®s, ®s);
|
||||
*ptr = '.';
|
||||
if (error != NULL)
|
||||
if (error != NULL) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _kernel_swi(OS_File, ®s, ®s);
|
||||
@@ -140,14 +142,15 @@ SDL_GetBasePath(void)
|
||||
}
|
||||
|
||||
canon = canonicalisePath((const char *)regs.r[0], "Run$Path");
|
||||
if (!canon) {
|
||||
if (canon == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* chop off filename. */
|
||||
ptr = SDL_strrchr(canon, '.');
|
||||
if (ptr != NULL)
|
||||
if (ptr != NULL) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
|
||||
retval = SDL_unixify_std(canon, NULL, 0, __RISCOSIFY_FILETYPE_NOTSPECIFIED);
|
||||
SDL_free(canon);
|
||||
@@ -161,22 +164,22 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
size_t len;
|
||||
_kernel_oserror *error;
|
||||
|
||||
if (!app) {
|
||||
if (app == NULL) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if (!org) {
|
||||
if (org == NULL) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
canon = canonicalisePath("<Choices$Write>", "Run$Path");
|
||||
if (!canon) {
|
||||
if (canon == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4;
|
||||
dir = (char *) SDL_malloc(len);
|
||||
if (!dir) {
|
||||
if (dir == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
SDL_free(canon);
|
||||
return NULL;
|
||||
|
||||
@@ -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 = '/';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,11 @@ 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 = "";
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
|
||||
len += SDL_strlen(org) + SDL_strlen(app) + 3;
|
||||
retval = (char *) SDL_malloc(len);
|
||||
if (!retval) {
|
||||
if (retval == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ SDL_GetBasePath(void)
|
||||
|
||||
while (SDL_TRUE) {
|
||||
void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR));
|
||||
if (!ptr) {
|
||||
if (ptr == NULL) {
|
||||
SDL_free(path);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -98,11 +98,11 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
size_t new_wpath_len = 0;
|
||||
BOOL api_result = FALSE;
|
||||
|
||||
if (!app) {
|
||||
if (app == NULL) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if (!org) {
|
||||
if (org == NULL) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
|
||||
}
|
||||
|
||||
const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
|
||||
if (!ucs2Path) {
|
||||
if (ucs2Path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -123,14 +123,14 @@ SDL_GetBasePath(void)
|
||||
size_t destPathLen;
|
||||
char * destPath = NULL;
|
||||
|
||||
if (!srcPath) {
|
||||
if (srcPath == NULL) {
|
||||
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
destPathLen = SDL_strlen(srcPath) + 2;
|
||||
destPath = (char *) SDL_malloc(destPathLen);
|
||||
if (!destPath) {
|
||||
if (destPath == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -156,16 +156,16 @@ SDL_GetPrefPath(const char *org, const char *app)
|
||||
size_t new_wpath_len = 0;
|
||||
BOOL api_result = FALSE;
|
||||
|
||||
if (!app) {
|
||||
if (app == NULL) {
|
||||
SDL_InvalidParamError("app");
|
||||
return NULL;
|
||||
}
|
||||
if (!org) {
|
||||
if (org == NULL) {
|
||||
org = "";
|
||||
}
|
||||
|
||||
srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER);
|
||||
if ( ! srcPath) {
|
||||
if (srcPath == NULL) {
|
||||
SDL_SetError("Unable to find a source path");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user