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,49 +823,48 @@ 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)
{
int reference_depth = 1;
config_file_t *conf = config_file_new_from_path_to_string(path);
char* nested_reference_path = (char*)malloc(PATH_MAX_LENGTH);
if (!conf)
goto end;
else
while (conf->reference)
{
int reference_depth = 1;
while (conf->reference)
/* If we have reached the max depth of nested references,
* stop attempting to read the next reference,
* 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 we have reached the max depth of nested references stop attempting to read
* the next reference 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)
{
RARCH_ERR("[ Shaders - Get Root Preset ]: Exceeded maximum reference depth(%u) without finding a full preset. "
"This chain of referenced presets is likely cyclical.\n", SHADER_MAX_REFERENCE_DEPTH);
config_file_free(conf);
conf = NULL;
goto end;
}
/* Get the absolute path for the reference */
fill_pathname_expanded_and_absolute(nested_reference_path, conf->path, conf->reference);
/* Create a new config from the referenced path */
RARCH_ERR("[ Shaders - Get Root Preset ]: Exceeded maximum reference depth(%u) without finding a full preset. "
"This chain of referenced presets is likely cyclical.\n", SHADER_MAX_REFERENCE_DEPTH);
config_file_free(conf);
conf = config_file_new_from_path_to_string(nested_reference_path);
/* If we can't read the reference preset */
if (!conf)
{
RARCH_WARN("[ Shaders ]: Could not read shader preset in #reference line: %s\n", nested_reference_path);
goto end;
}
reference_depth += 1;
conf = NULL;
goto end;
}
/* Get the absolute path for the reference */
fill_pathname_expanded_and_absolute(nested_reference_path, conf->path, conf->reference);
/* Create a new config from the referenced path */
config_file_free(conf);
conf = config_file_new_from_path_to_string(nested_reference_path);
/* If we can't read the reference preset */
if (!conf)
{
RARCH_WARN("[ Shaders ]: Could not read shader preset in #reference line: %s\n", nested_reference_path);
goto end;
}
reference_depth += 1;
}
end:
end:
free(nested_reference_path);
return conf;
@ -899,9 +898,10 @@ 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)
{
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* path_to_save_conformed = (char*)malloc(PATH_MAX_LENGTH);
char* path_to_save_conformed = (char*)malloc(PATH_MAX_LENGTH);
bool return_val = true;
strlcpy(path_to_save_conformed, path_to_save, PATH_MAX_LENGTH);
@ -1602,13 +1602,11 @@ bool video_shader_load_preset_into_shader(const char *path, struct video_shader
{
unsigned i = 0;
bool ret = true;
int reference_depth = 1;
char override_conf_paths[SHADER_MAX_REFERENCE_DEPTH][PATH_MAX_LENGTH];
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 */
root_conf = video_shader_get_root_preset_config(path);
config_file_t *root_conf =
video_shader_get_root_preset_config(path);
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 */
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_refpath_conformed[PATH_MAX_LENGTH];
char expanded_path[PATH_MAX_LENGTH];
@ -1162,44 +1159,45 @@ void fill_pathname_abbreviated_or_relative(char *out_path, const char *in_refpat
char relative_path[PATH_MAX_LENGTH];
char abbreviated_path[PATH_MAX_LENGTH];
in_path_conformed[0] = '\0';
in_path_conformed[0] = '\0';
in_refpath_conformed[0] = '\0';
absolute_path[0] = '\0';
relative_path[0] = '\0';
abbreviated_path[0] = '\0';
absolute_path[0] = '\0';
relative_path[0] = '\0';
abbreviated_path[0] = '\0';
strcpy(in_path_conformed, in_path);
strcpy(in_refpath_conformed, in_refpath);
strcpy_literal(in_path_conformed, in_path);
strcpy_literal(in_refpath_conformed, in_refpath);
pathname_conform_slashes_to_os(in_path_conformed);
pathname_conform_slashes_to_os(in_refpath_conformed);
/* 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 */
if (path_is_absolute(expanded_path))
strlcpy(absolute_path, expanded_path, PATH_MAX_LENGTH);
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);
/* 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 */
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*/
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);
}
else
{
retro_assert(strlcpy(out_path, abbreviated_path, size) < size);
}
}
/**