Use new parameter validation macro

This commit is contained in:
Sam Lantinga
2025-09-16 21:51:03 -07:00
parent ee1c90a358
commit 25b2d2c821
60 changed files with 1113 additions and 1133 deletions

View File

@@ -27,7 +27,7 @@
bool SDL_RemovePath(const char *path)
{
if (!path) {
CHECK_PARAM(!path) {
return SDL_InvalidParamError("path");
}
return SDL_SYS_RemovePath(path);
@@ -35,9 +35,10 @@ bool SDL_RemovePath(const char *path)
bool SDL_RenamePath(const char *oldpath, const char *newpath)
{
if (!oldpath) {
CHECK_PARAM(!oldpath) {
return SDL_InvalidParamError("oldpath");
} else if (!newpath) {
}
CHECK_PARAM(!newpath) {
return SDL_InvalidParamError("newpath");
}
return SDL_SYS_RenamePath(oldpath, newpath);
@@ -45,9 +46,10 @@ bool SDL_RenamePath(const char *oldpath, const char *newpath)
bool SDL_CopyFile(const char *oldpath, const char *newpath)
{
if (!oldpath) {
CHECK_PARAM(!oldpath) {
return SDL_InvalidParamError("oldpath");
} else if (!newpath) {
}
CHECK_PARAM(!newpath) {
return SDL_InvalidParamError("newpath");
}
return SDL_SYS_CopyFile(oldpath, newpath);
@@ -55,7 +57,7 @@ bool SDL_CopyFile(const char *oldpath, const char *newpath)
bool SDL_CreateDirectory(const char *path)
{
if (!path) {
CHECK_PARAM(!path) {
return SDL_InvalidParamError("path");
}
@@ -116,9 +118,10 @@ bool SDL_CreateDirectory(const char *path)
bool SDL_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback callback, void *userdata)
{
if (!path) {
CHECK_PARAM(!path) {
return SDL_InvalidParamError("path");
} else if (!callback) {
}
CHECK_PARAM(!callback) {
return SDL_InvalidParamError("callback");
}
return SDL_SYS_EnumerateDirectory(path, callback, userdata);
@@ -133,10 +136,9 @@ bool SDL_GetPathInfo(const char *path, SDL_PathInfo *info)
}
SDL_zerop(info);
if (!path) {
CHECK_PARAM(!path) {
return SDL_InvalidParamError("path");
}
return SDL_SYS_GetPathInfo(path, info);
}
@@ -364,7 +366,7 @@ char **SDL_InternalGlobDirectory(const char *path, const char *pattern, SDL_Glob
}
*count = 0;
if (!path) {
CHECK_PARAM(!path) {
SDL_InvalidParamError("path");
return NULL;
}
@@ -488,7 +490,8 @@ static char *CachedUserFolders[SDL_FOLDER_COUNT];
const char *SDL_GetUserFolder(SDL_Folder folder)
{
const int idx = (int) folder;
if ((idx < 0) || (idx >= SDL_arraysize(CachedUserFolders))) {
CHECK_PARAM((idx < 0) || (idx >= SDL_arraysize(CachedUserFolders))) {
SDL_InvalidParamError("folder");
return NULL;
}
@@ -502,7 +505,7 @@ const char *SDL_GetUserFolder(SDL_Folder folder)
char *SDL_GetPrefPath(const char *org, const char *app)
{
if (!app) {
CHECK_PARAM(!app) {
SDL_InvalidParamError("app");
return NULL;
}