]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/load-droping: avoid oom warning when the unit symlink is not a template 6000/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 20 May 2017 23:34:50 +0000 (19:34 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 20 May 2017 23:34:50 +0000 (19:34 -0400)
unit_name_template returns -EINVAL if the unit name is not a template, but
the code assumed that OOM is the only failure mode. Fix that to emit the warning
if a non-template unit is encountered (because in this case we expect the name
to match exactly), and just skip the warning on other errors (presumably oom).

Fixes #5543.

src/core/load-dropin.c

index ff3636149a8b0cae4c817564395965427dab9703..3180f911bb7a65b9f4f0a203aee3885ca668fe1d 100644 (file)
@@ -38,10 +38,12 @@ static bool unit_name_compatible(const char *a, const char *b) {
                 return true;
 
         r = unit_name_template(a, &prefix);
-        if (r < 0) {
-                log_oom();
+        if (r == -EINVAL)
+                /* not a template */
+                return false;
+        if (r < 0)
+                /* oom, or some other failure. Just skip the warning. */
                 return true;
-        }
 
         /* an instance name points to a target that is just the template name */
         if (streq(prefix, b))