summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-11-09 06:40:02 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-11-09 06:40:05 +0100
commit601844b71dd2414c8c015192c8b11cbf89cfc2cb (patch)
tree3c21d86407e5a58cc4e6a53cc025cc48e493e4e3 /src/core
parentsd-bus: fix possible division by 0 (diff)
downloadsystemd-601844b71dd2414c8c015192c8b11cbf89cfc2cb.tar.xz
systemd-601844b71dd2414c8c015192c8b11cbf89cfc2cb.zip
core: reduce scope of variants
Fixes #17543.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/load-fragment.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 0ab64e1708..5f8b0fedf0 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -5646,9 +5646,7 @@ void unit_dump_config_items(FILE *f) {
NULSTR_FOREACH(i, load_fragment_gperf_nulstr) {
const char *rvalue = "OTHER", *lvalue;
const ConfigPerfItem *p;
- size_t prefix_len;
const char *dot;
- unsigned j;
assert_se(p = load_fragment_gperf_lookup(i, strlen(i)));
@@ -5657,7 +5655,7 @@ void unit_dump_config_items(FILE *f) {
p->ltype == DISABLED_LEGACY)
continue;
- for (j = 0; j < ELEMENTSOF(table); j++)
+ for (size_t j = 0; j < ELEMENTSOF(table); j++)
if (p->parse == table[j].callback) {
rvalue = table[j].rvalue;
break;
@@ -5665,15 +5663,17 @@ void unit_dump_config_items(FILE *f) {
dot = strchr(i, '.');
lvalue = dot ? dot + 1 : i;
- prefix_len = dot-i;
- if (dot)
+ if (dot) {
+ size_t prefix_len = dot - i;
+
if (!prev || !strneq(prev, i, prefix_len+1)) {
if (prev)
fputc('\n', f);
fprintf(f, "[%.*s]\n", (int) prefix_len, i);
}
+ }
fprintf(f, "%s=%s\n", lvalue, rvalue);
prev = i;