]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/conf-parser: do not print "(null)" as section name 32994/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 May 2024 12:47:00 +0000 (14:47 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 23 May 2024 14:15:24 +0000 (16:15 +0200)
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.

src/shared/conf-parser.c

index 277f4ee42fd82b4e1e0cb5be1e64b8c029eef916..fcc45c6e252f140544e0ac82982e0614a797325a 100644 (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;
 }