[SDL2] pointer boolean (#8523)

This commit is contained in:
Sylvain Becker
2023-11-10 15:30:56 +01:00
committed by GitHub
parent 4a3a9f3ad8
commit a14b948b6c
394 changed files with 2564 additions and 2559 deletions

View File

@@ -45,7 +45,7 @@ char *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 == NULL) {
if (!fullpath) {
SDL_OutOfMemory();
return NULL;
}

View File

@@ -45,17 +45,17 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

View File

@@ -44,7 +44,7 @@ SDL_GetBasePath(void)
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof(CHAR));
if (ptr == NULL) {
if (!ptr) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
@@ -90,13 +90,13 @@ SDL_GetPrefPath(const char *org, const char *app)
HRESULT result;
const char *csid = SDL_GetHint("SDL_GDK_SERVICE_CONFIGURATION_ID");
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
/* This should be set before calling SDL_GetPrefPath! */
if (csid == NULL) {
if (!csid) {
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Set SDL_GDK_SERVICE_CONFIGURATION_ID before calling SDL_GetPrefPath!");
return SDL_strdup("T:\\");
}

View File

@@ -52,11 +52,11 @@ char *SDL_GetBasePath(void)
rc = path.GetParent(&path); /* chop filename, keep directory. */
SDL_assert(rc == B_OK);
const char *str = path.Path();
SDL_assert(str != NULL);
SDL_assert(str);
const size_t len = SDL_strlen(str);
char *retval = (char *) SDL_malloc(len + 2);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@@ -75,11 +75,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
const char *append = "/config/settings/";
size_t len = SDL_strlen(home);
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@@ -88,7 +88,7 @@ char *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 == NULL) {
if (!retval) {
SDL_OutOfMemory();
} else {
if (*org) {

View File

@@ -44,13 +44,13 @@ char *SDL_GetBasePath(void)
char *SDL_GetPrefPath(const char *org, const char *app)
{
char *pref_path = NULL;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
pref_path = MakePrefPath(app);
if (pref_path == NULL) {
if (!pref_path) {
return NULL;
}

View File

@@ -82,11 +82,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}

View File

@@ -50,11 +50,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}

View File

@@ -38,21 +38,21 @@ static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len,
{
const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */
if (buffer == NULL) {
if (!buffer) {
/* 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 == NULL) {
if (!buffer) {
SDL_OutOfMemory();
return NULL;
}
}
if (!__unixify_std(ro_path, buffer, buf_len, filetype)) {
if (in_buf == NULL) {
if (!in_buf) {
SDL_free(buffer);
}
@@ -92,7 +92,7 @@ static char *canonicalisePath(const char *path, const char *pathVar)
regs.r[5] = 1 - regs.r[5];
buf = SDL_malloc(regs.r[5]);
if (buf == NULL) {
if (!buf) {
SDL_OutOfMemory();
return NULL;
}
@@ -121,7 +121,7 @@ static _kernel_oserror *createDirectoryRecursive(char *path)
*ptr = '\0';
error = _kernel_swi(OS_File, &regs, &regs);
*ptr = '.';
if (error != NULL) {
if (error) {
return error;
}
}
@@ -141,13 +141,13 @@ char *SDL_GetBasePath(void)
}
canon = canonicalisePath((const char *)regs.r[0], "Run$Path");
if (canon == NULL) {
if (!canon) {
return NULL;
}
/* chop off filename. */
ptr = SDL_strrchr(canon, '.');
if (ptr != NULL) {
if (ptr) {
*ptr = '\0';
}
@@ -162,22 +162,22 @@ char *SDL_GetPrefPath(const char *org, const char *app)
size_t len;
_kernel_oserror *error;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
canon = canonicalisePath("<Choices$Write>", "Run$Path");
if (canon == NULL) {
if (!canon) {
return NULL;
}
len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4;
dir = (char *)SDL_malloc(len);
if (dir == NULL) {
if (!dir) {
SDL_OutOfMemory();
SDL_free(canon);
return NULL;
@@ -192,7 +192,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
SDL_free(canon);
error = createDirectoryRecursive(dir);
if (error != NULL) {
if (error) {
SDL_SetError("Couldn't create directory: %s", error->errmess);
SDL_free(dir);
return NULL;

View File

@@ -53,7 +53,7 @@ static char *readSymLink(const char *path)
while (1) {
char *ptr = (char *)SDL_realloc(retval, (size_t)len);
if (ptr == NULL) {
if (!ptr) {
SDL_OutOfMemory();
break;
}
@@ -86,18 +86,18 @@ static char *search_path_for_binary(const char *bin)
char *start = envr;
char *ptr;
if (envr == NULL) {
if (!envr) {
SDL_SetError("No $PATH set");
return NULL;
}
envr = SDL_strdup(envr);
if (envr == NULL) {
if (!envr) {
SDL_OutOfMemory();
return NULL;
}
SDL_assert(bin != NULL);
SDL_assert(bin);
alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2;
exe = (char *)SDL_malloc(alloc_size);
@@ -118,7 +118,7 @@ static char *search_path_for_binary(const char *bin)
}
}
start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
} while (ptr);
SDL_free(envr);
SDL_free(exe);
@@ -138,7 +138,7 @@ char *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 == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@@ -152,13 +152,13 @@ char *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 == NULL) {
if (!realpathbuf) {
SDL_OutOfMemory();
return NULL;
}
cmdline = SDL_malloc(len);
if (cmdline == NULL) {
if (!cmdline) {
SDL_free(realpathbuf);
SDL_OutOfMemory();
return NULL;
@@ -180,7 +180,7 @@ char *SDL_GetBasePath(void)
}
if (exe) {
if (pwddst == NULL) {
if (!pwddst) {
if (realpath(exe, realpathbuf) != NULL) {
retval = realpathbuf;
}
@@ -196,7 +196,7 @@ char *SDL_GetBasePath(void)
}
}
if (retval == NULL) {
if (!retval) {
SDL_free(realpathbuf);
}
@@ -205,7 +205,7 @@ char *SDL_GetBasePath(void)
#endif
/* is a Linux-style /proc filesystem available? */
if (retval == NULL && (access("/proc", F_OK) == 0)) {
if (!retval && (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. */
@@ -219,7 +219,7 @@ char *SDL_GetBasePath(void)
retval = SDL_LoadFile("/proc/self/exefile", NULL);
#else
retval = readSymLink("/proc/self/exe"); /* linux. */
if (retval == NULL) {
if (!retval) {
/* older kernels don't have /proc/self ... try PID version... */
char path[64];
const int rc = SDL_snprintf(path, sizeof(path),
@@ -248,9 +248,9 @@ char *SDL_GetBasePath(void)
/* If we had access to argv[0] here, we could check it for a path,
or troll through $PATH looking for it, too. */
if (retval != NULL) { /* chop off filename. */
if (retval) { /* chop off filename. */
char *ptr = SDL_strrchr(retval, '/');
if (ptr != NULL) {
if (ptr) {
*(ptr + 1) = '\0';
} else { /* shouldn't happen, but just in case... */
SDL_free(retval);
@@ -258,10 +258,10 @@ char *SDL_GetBasePath(void)
}
}
if (retval != NULL) {
if (retval) {
/* try to shrink buffer... */
char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1);
if (ptr != NULL) {
if (ptr) {
retval = ptr; /* oh well if it failed. */
}
}
@@ -284,18 +284,18 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
if (envr == NULL) {
if (!envr) {
/* You end up with "$HOME/.local/share/Game Name 2" */
envr = SDL_getenv("HOME");
if (envr == NULL) {
if (!envr) {
/* we could take heroic measures with /etc/passwd, but oh well. */
SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
return NULL;
@@ -312,7 +312,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

View File

@@ -53,11 +53,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@@ -65,7 +65,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
len += SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

View File

@@ -42,7 +42,7 @@ char *SDL_GetBasePath(void)
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR));
if (ptr == NULL) {
if (!ptr) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
@@ -99,11 +99,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@@ -113,13 +113,13 @@ char *SDL_GetPrefPath(const char *org, const char *app)
}
worg = WIN_UTF8ToStringW(org);
if (worg == NULL) {
if (!worg) {
SDL_OutOfMemory();
return NULL;
}
wapp = WIN_UTF8ToStringW(app);
if (wapp == NULL) {
if (!wapp) {
SDL_free(worg);
SDL_OutOfMemory();
return NULL;

View File

@@ -111,7 +111,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
}
const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
if (ucs2Path == NULL) {
if (!ucs2Path) {
return NULL;
}
@@ -128,14 +128,14 @@ SDL_GetBasePath(void)
size_t destPathLen;
char *destPath = NULL;
if (srcPath == NULL) {
if (!srcPath) {
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
return NULL;
}
destPathLen = SDL_strlen(srcPath) + 2;
destPath = (char *)SDL_malloc(destPathLen);
if (destPath == NULL) {
if (!destPath) {
SDL_OutOfMemory();
return NULL;
}
@@ -161,16 +161,16 @@ SDL_GetPrefPath(const char *org, const char *app)
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER);
if (srcPath == NULL) {
if (!srcPath) {
SDL_SetError("Unable to find a source path");
return NULL;
}
@@ -182,13 +182,13 @@ SDL_GetPrefPath(const char *org, const char *app)
SDL_wcslcpy(path, srcPath, SDL_arraysize(path));
worg = WIN_UTF8ToString(org);
if (worg == NULL) {
if (!worg) {
SDL_OutOfMemory();
return NULL;
}
wapp = WIN_UTF8ToString(app);
if (wapp == NULL) {
if (!wapp) {
SDL_free(worg);
SDL_OutOfMemory();
return NULL;