sysctl: always return the last error we encountered

This commit is contained in:
Lennart Poettering 2012-09-21 17:01:39 +02:00
parent 77e63fafa5
commit 0187f62bb5
1 changed files with 9 additions and 9 deletions

View File

@ -252,7 +252,7 @@ static int parse_argv(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
int r = 0;
int r = 0, k;
char *property, *value;
Iterator it;
@ -260,8 +260,6 @@ int main(int argc, char *argv[]) {
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
r = 0;
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
@ -274,19 +272,18 @@ int main(int argc, char *argv[]) {
goto finish;
}
r = 0;
if (argc > optind) {
int i;
for (i = optind; i < argc; i++) {
int k;
k = parse_file(argv[i], false);
if (k < 0 && r == 0)
if (k < 0)
r = k;
}
} else {
char **files, **f;
int k;
r = conf_files_list(&files, ".conf",
"/etc/sysctl.d",
@ -310,14 +307,17 @@ int main(int argc, char *argv[]) {
f = files + strv_length(files) - 1;
STRV_FOREACH_BACKWARDS(f, files) {
k = parse_file(*f, true);
if (k < 0 && r == 0)
if (k < 0)
r = k;
}
strv_free(files);
}
r = apply_all();
k = apply_all();
if (k < 0)
r = k;
finish:
HASHMAP_FOREACH_KEY(value, property, sysctl_options, it) {
hashmap_remove(sysctl_options, property);