Cleanups/remove unused variables

This commit is contained in:
twinaphex 2021-01-16 17:17:16 +01:00
parent bc48080ee5
commit 552f973833
2 changed files with 52 additions and 56 deletions

View File

@ -823,20 +823,21 @@ bool video_shader_write_root_preset(const struct video_shader *shader, const cha
config_file_t *video_shader_get_root_preset_config(const char *path) config_file_t *video_shader_get_root_preset_config(const char *path)
{ {
int reference_depth = 1;
config_file_t *conf = config_file_new_from_path_to_string(path); config_file_t *conf = config_file_new_from_path_to_string(path);
char* nested_reference_path = (char*)malloc(PATH_MAX_LENGTH); char* nested_reference_path = (char*)malloc(PATH_MAX_LENGTH);
if (!conf) if (!conf)
goto end; goto end;
else
{
int reference_depth = 1;
while (conf->reference) while (conf->reference)
{ {
/* If we have reached the max depth of nested references stop attempting to read /* If we have reached the max depth of nested references,
* the next reference because we are likely in a self referential loop. * stop attempting to read the next reference,
* SHADER_MAX_REFERENCE_DEPTH references deep seems like more than enough depth for expected usage */ * because we are likely in a self referential loop.
*
* SHADER_MAX_REFERENCE_DEPTH references deep seems
* like more than enough depth for expected usage */
if (reference_depth > SHADER_MAX_REFERENCE_DEPTH) if (reference_depth > SHADER_MAX_REFERENCE_DEPTH)
{ {
RARCH_ERR("[ Shaders - Get Root Preset ]: Exceeded maximum reference depth(%u) without finding a full preset. " RARCH_ERR("[ Shaders - Get Root Preset ]: Exceeded maximum reference depth(%u) without finding a full preset. "
@ -862,10 +863,8 @@ config_file_t *video_shader_get_root_preset_config(const char *path)
reference_depth += 1; reference_depth += 1;
} }
}
end:
end:
free(nested_reference_path); free(nested_reference_path);
return conf; return conf;
@ -899,7 +898,8 @@ config_file_t *video_shader_get_root_preset_config(const char *path)
**/ **/
bool video_shader_check_reference_chain_for_save(const char *path_to_save, const char *reference_path) bool video_shader_check_reference_chain_for_save(const char *path_to_save, const char *reference_path)
{ {
config_file_t *conf = config_file_new_from_path_to_string(reference_path); config_file_t *conf = config_file_new_from_path_to_string(
reference_path);
char* nested_reference_path = (char*)malloc(PATH_MAX_LENGTH); char* nested_reference_path = (char*)malloc(PATH_MAX_LENGTH);
char* path_to_save_conformed = (char*)malloc(PATH_MAX_LENGTH); char* path_to_save_conformed = (char*)malloc(PATH_MAX_LENGTH);
bool return_val = true; bool return_val = true;
@ -1602,13 +1602,11 @@ bool video_shader_load_preset_into_shader(const char *path, struct video_shader
{ {
unsigned i = 0; unsigned i = 0;
bool ret = true; bool ret = true;
int reference_depth = 1;
char override_conf_paths[SHADER_MAX_REFERENCE_DEPTH][PATH_MAX_LENGTH]; char override_conf_paths[SHADER_MAX_REFERENCE_DEPTH][PATH_MAX_LENGTH];
config_file_t *conf = NULL; config_file_t *conf = NULL;
config_file_t *root_conf = NULL;
/* Get the root config, If we were able to get a root_config that means the reference chain is valid */ /* Get the root config, If we were able to get a root_config that means the reference chain is valid */
root_conf = video_shader_get_root_preset_config(path); config_file_t *root_conf =
video_shader_get_root_preset_config(path);
if (!root_conf) if (!root_conf)
{ {

View File

@ -1152,9 +1152,6 @@ int get_pathname_num_slashes(const char *in_path)
* in_path can be an absolute, relative or abbreviated path */ * in_path can be an absolute, relative or abbreviated path */
void fill_pathname_abbreviated_or_relative(char *out_path, const char *in_refpath, const char *in_path, size_t size) void fill_pathname_abbreviated_or_relative(char *out_path, const char *in_refpath, const char *in_path, size_t size)
{ {
unsigned relative_length = 0;
unsigned abbreviated_length = 0;
char in_path_conformed[PATH_MAX_LENGTH]; char in_path_conformed[PATH_MAX_LENGTH];
char in_refpath_conformed[PATH_MAX_LENGTH]; char in_refpath_conformed[PATH_MAX_LENGTH];
char expanded_path[PATH_MAX_LENGTH]; char expanded_path[PATH_MAX_LENGTH];
@ -1168,38 +1165,39 @@ void fill_pathname_abbreviated_or_relative(char *out_path, const char *in_refpat
relative_path[0] = '\0'; relative_path[0] = '\0';
abbreviated_path[0] = '\0'; abbreviated_path[0] = '\0';
strcpy(in_path_conformed, in_path); strcpy_literal(in_path_conformed, in_path);
strcpy(in_refpath_conformed, in_refpath); strcpy_literal(in_refpath_conformed, in_refpath);
pathname_conform_slashes_to_os(in_path_conformed); pathname_conform_slashes_to_os(in_path_conformed);
pathname_conform_slashes_to_os(in_refpath_conformed); pathname_conform_slashes_to_os(in_refpath_conformed);
/* Expand paths which start with :\ to an absolute path */ /* Expand paths which start with :\ to an absolute path */
fill_pathname_expand_special(expanded_path, in_path_conformed, sizeof(expanded_path)); fill_pathname_expand_special(expanded_path,
in_path_conformed, sizeof(expanded_path));
/* Get the absolute path if it is not already */ /* Get the absolute path if it is not already */
if (path_is_absolute(expanded_path)) if (path_is_absolute(expanded_path))
strlcpy(absolute_path, expanded_path, PATH_MAX_LENGTH); strlcpy(absolute_path, expanded_path, PATH_MAX_LENGTH);
else else
fill_pathname_resolve_relative(absolute_path, in_refpath_conformed, in_path_conformed, PATH_MAX_LENGTH); fill_pathname_resolve_relative(absolute_path,
in_refpath_conformed, in_path_conformed, PATH_MAX_LENGTH);
pathname_conform_slashes_to_os(absolute_path); pathname_conform_slashes_to_os(absolute_path);
/* Get the relative path and see how many directories long it is */ /* Get the relative path and see how many directories long it is */
path_relative_to(relative_path, absolute_path, in_refpath_conformed, sizeof(relative_path)); path_relative_to(relative_path, absolute_path,
in_refpath_conformed, sizeof(relative_path));
/* Get the abbreviated path and see how many directories long it is */ /* Get the abbreviated path and see how many directories long it is */
fill_pathname_abbreviate_special(abbreviated_path, absolute_path, sizeof(abbreviated_path)); fill_pathname_abbreviate_special(abbreviated_path,
absolute_path, sizeof(abbreviated_path));
/* Use the shortest path, preferring the relative path*/ /* Use the shortest path, preferring the relative path*/
if (get_pathname_num_slashes(relative_path) <= get_pathname_num_slashes(abbreviated_path)) if ( get_pathname_num_slashes(relative_path) <=
{ get_pathname_num_slashes(abbreviated_path))
retro_assert(strlcpy(out_path, relative_path, size) < size); retro_assert(strlcpy(out_path, relative_path, size) < size);
}
else else
{
retro_assert(strlcpy(out_path, abbreviated_path, size) < size); retro_assert(strlcpy(out_path, abbreviated_path, size) < size);
}
} }
/** /**