Code cleanup

This commit is contained in:
Pierre Pronchery 2017-11-09 04:56:22 +01:00
parent 36c1e62388
commit 8102619275
2 changed files with 5 additions and 11 deletions

View File

@ -401,11 +401,10 @@ static int _configure_load(ConfigurePrefs * prefs, String const * directory,
String * path; String * path;
String const * subdirs = NULL; String const * subdirs = NULL;
if((path = string_new(directory)) == NULL) if((path = string_new_append(directory, "/", PROJECT_CONF, NULL))
== NULL)
return configure_error(1, "%s", error_get(NULL)); return configure_error(1, "%s", error_get(NULL));
if(string_append(&path, "/") != 0 if((config = config_new()) == NULL)
|| string_append(&path, PROJECT_CONF) != 0
|| (config = config_new()) == NULL)
{ {
string_delete(path); string_delete(path);
return configure_error(1, "%s", error_get(NULL)); return configure_error(1, "%s", error_get(NULL));

View File

@ -111,14 +111,9 @@ static int _settings_do(Configure * configure, String const * directory,
} }
if(configure_is_flag_set(configure, PREFS_n)) if(configure_is_flag_set(configure, PREFS_n))
return 0; return 0;
if((filename = string_new(directory)) == NULL) if((filename = string_new_append(directory, "/config.", extension,
NULL)) == NULL)
return 1; return 1;
if(string_append(&filename, "/config.") != 0
|| string_append(&filename, extension) != 0)
{
string_delete(filename);
return 1;
}
if((fp = fopen(filename, "w")) == NULL) if((fp = fopen(filename, "w")) == NULL)
configure_error(0, "%s: %s", filename, strerror(errno)); configure_error(0, "%s: %s", filename, strerror(errno));
string_delete(filename); string_delete(filename);