shared/conf-parser: do not print "(null)" as section name

Before:
/etc/kernel/install.conf:6: Unknown key name 'asdf' in section '(null)', ignoring.
After:
/etc/kernel/install.conf:6: Unknown key 'asdf', ignoring.

Also make the message a bit better.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2024-05-23 14:47:00 +02:00
parent 3f5196ffb8
commit 600a7405a9

View File

@@ -160,7 +160,11 @@ static int next_assignment(
/* Warn about unknown non-extension fields. */
if (!(flags & CONFIG_PARSE_RELAXED) && !startswith(lvalue, "X-"))
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unknown key name '%s' in section '%s', ignoring.", lvalue, section);
"Unknown key '%s'%s%s%s, ignoring.",
lvalue,
section ? " in section [" : "",
strempty(section),
section ? "]" : "");
return 0;
}