Merge pull request #11006 from poettering/conf-file-fix

minor fixes for conf-files.c
This commit is contained in:
Lennart Poettering 2018-12-01 00:47:22 +01:00 committed by GitHub
commit 2c8f15aeca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 16 deletions

View file

@ -189,11 +189,12 @@ int conf_files_insert(char ***strv, const char *root, char **dirs, const char *p
* - do nothing if our new entry matches the existing entry,
* - replace the existing entry if our new entry has higher priority.
*/
size_t i;
size_t i, n;
char *t;
int r;
for (i = 0; i < strv_length(*strv); i++) {
n = strv_length(*strv);
for (i = 0; i < n; i++) {
int c;
c = base_cmp((char* const*) *strv + i, (char* const*) &path);
@ -234,26 +235,15 @@ int conf_files_insert(char ***strv, const char *root, char **dirs, const char *p
t = path_join(root, path);
if (!t)
return log_oom();
return -ENOMEM;
r = strv_insert(strv, i, t);
if (r < 0)
free(t);
return r;
}
int conf_files_insert_nulstr(char ***strv, const char *root, const char *dirs, const char *path) {
_cleanup_strv_free_ char **d = NULL;
assert(strv);
d = strv_split_nulstr(dirs);
if (!d)
return -ENOMEM;
return conf_files_insert(strv, root, d, path);
}
int conf_files_list_strv(char ***strv, const char *suffix, const char *root, unsigned flags, const char* const* dirs) {
_cleanup_strv_free_ char **copy = NULL;

View file

@ -15,7 +15,6 @@ int conf_files_list(char ***ret, const char *suffix, const char *root, unsigned
int conf_files_list_strv(char ***ret, const char *suffix, const char *root, unsigned flags, const char* const* dirs);
int conf_files_list_nulstr(char ***ret, const char *suffix, const char *root, unsigned flags, const char *dirs);
int conf_files_insert(char ***strv, const char *root, char **dirs, const char *path);
int conf_files_insert_nulstr(char ***strv, const char *root, const char *dirs, const char *path);
int conf_files_list_with_replacement(
const char *root,
char **config_dirs,