chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemctl,loginctl,cgls: do not ellipsize cgroup members when --full is specified
[elogind.git]
/
src
/
sysctl
/
sysctl.c
diff --git
a/src/sysctl/sysctl.c
b/src/sysctl/sysctl.c
index 793796d36381a8909123502bb584647fcba35eb1..035e0ec321c5a4d951fd91e7761fc6430edb0f29 100644
(file)
--- a/
src/sysctl/sysctl.c
+++ b/
src/sysctl/sysctl.c
@@
-167,14
+167,18
@@
static int parse_file(const char *path, bool ignore_enoent) {
r = hashmap_put(sysctl_options, property, new_value);
if (r < 0) {
r = hashmap_put(sysctl_options, property, new_value);
if (r < 0) {
- if (r == -EEXIST)
+ if (r == -EEXIST) {
+ /* ignore this "error" to avoid returning it
+ * for the function when this is the last key
+ * in the file being parsed. */
+ r = 0;
log_debug("Skipping previously assigned sysctl variable %s", property);
log_debug("Skipping previously assigned sysctl variable %s", property);
- else
+
}
else
log_error("Failed to add sysctl variable %s to hashmap: %s", property, strerror(-r));
free(property);
free(new_value);
log_error("Failed to add sysctl variable %s to hashmap: %s", property, strerror(-r));
free(property);
free(new_value);
- if (r !=
-EEXIST
)
+ if (r !=
0
)
goto finish;
}
}
goto finish;
}
}
@@
-252,7
+256,7
@@
static int parse_argv(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
- int r = 0;
+ int r = 0
, k
;
char *property, *value;
Iterator it;
char *property, *value;
Iterator it;
@@
-272,19
+276,18
@@
int main(int argc, char *argv[]) {
goto finish;
}
goto finish;
}
+ r = 0;
+
if (argc > optind) {
int i;
for (i = optind; i < argc; i++) {
if (argc > optind) {
int i;
for (i = optind; i < argc; i++) {
- int k;
-
k = parse_file(argv[i], false);
k = parse_file(argv[i], false);
- if (k < 0
&& r == 0
)
+ if (k < 0)
r = k;
}
} else {
char **files, **f;
r = k;
}
} else {
char **files, **f;
- int k;
r = conf_files_list(&files, ".conf",
"/etc/sysctl.d",
r = conf_files_list(&files, ".conf",
"/etc/sysctl.d",
@@
-308,14
+311,17
@@
int main(int argc, char *argv[]) {
f = files + strv_length(files) - 1;
STRV_FOREACH_BACKWARDS(f, files) {
k = parse_file(*f, true);
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 = 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);
finish:
HASHMAP_FOREACH_KEY(value, property, sysctl_options, it) {
hashmap_remove(sysctl_options, property);