-
Notifications
You must be signed in to change notification settings - Fork 2.3k
filesystem: SDL_GetPrefPath handles NULL params at the top level now. #13361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -107,12 +99,7 @@ | |||
result = (char *)SDL_malloc(len); | |||
if (result != NULL) { | |||
char *ptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptr
outside of the loop becomes unused.
@@ -42,27 +42,13 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) | |||
const char *append = "/libsdl/"; | |||
char *result; | |||
char *ptr = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the above change, ptr
is only used in the for loop.
result
can be defined below as char* result = (char *)SDL_malloc(len);
; same for result
in many other implementations. (Or like other implementations, may be defined as char *result = NULL;
).
SDL_InvalidParamError("app"); | ||
return NULL; | ||
} | ||
|
||
pref_path = MakePrefPath(app); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be char *pref_path = MakePrefPath(app);
@@ -80,15 +80,6 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) | |||
char *result = NULL; | |||
size_t len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be defined below as const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
@@ -269,15 +269,6 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) | |||
const char *append; | |||
char *result = NULL; | |||
char *ptr = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptr
is used only in the for loop.
SDL_snprintf(result, len, "%s%s/", base, app); | ||
} | ||
|
||
SDL_snprintf(result, len, "%s%s/%s/", base, org, app); | ||
mkdir(result, 0755); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether to check for successfulness for mkdir-like functions? I notice some implementations check while some not...
@@ -33,7 +33,7 @@ char *SDL_SYS_GetBasePath(void) | |||
char *SDL_SYS_GetPrefPath(const char *org, const char *app) | |||
{ | |||
char *pref_path = NULL; | |||
if (SDL_asprintf(&pref_path, "C:/System/Apps/%s/%s/", org ? org : "SDL_App", app) < 0) { | |||
if (SDL_asprintf(&pref_path, "C:/System/Apps/%s/%s/", org, app) < 0) { | |||
return NULL; | |||
} | |||
return pref_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no mkdir-like call for this implementation, is it correct? (I'm not familiar with the background.)
@@ -269,15 +269,6 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) | |||
const char *append; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May init to NULL
.
@@ -46,29 +46,13 @@ char *SDL_SYS_GetPrefPath(const char *org, const char *app) | |||
const char *envr = "ux0:/data/"; | |||
char *result = NULL; | |||
char *ptr = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ptr
is used only in the for loop.
Doesn't this break existing apps that relied on the old behaviour? |
I intentionally set |
This isn't really a good idea. Plenty of Windows applications use just a single folder in AppData rather than nesting, so this would prevent anyone from making an application like that. |
Fixes #13322.