]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
load-dropin: propagate errors properly from unit_name_compatible() (#6002)
authorLennart Poettering <lennart@poettering.net>
Mon, 22 May 2017 13:18:00 +0000 (15:18 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 22 May 2017 13:18:00 +0000 (09:18 -0400)
Let's log about this in the caller.

Doesn't really matter, but let's do something about my OCD, and
propagate errors properly, so that the caller can log about them.

src/core/load-dropin.c

index 3180f911bb7a65b9f4f0a203aee3885ca668fe1d..00f09ce60a3d40e64e08a2a56bc15666a7c93566 100644 (file)
 #include "unit-name.h"
 #include "unit.h"
 
-static bool unit_name_compatible(const char *a, const char *b) {
+static int unit_name_compatible(const char *a, const char *b) {
         _cleanup_free_ char *prefix = NULL;
         int r;
 
         /* the straightforward case: the symlink name matches the target */
         if (streq(a, b))
-                return true;
+                return 1;
 
         r = unit_name_template(a, &prefix);
         if (r == -EINVAL)
                 /* not a template */
-                return false;
+                return 0;
         if (r < 0)
                 /* oom, or some other failure. Just skip the warning. */
-                return true;
+                return r;
 
         /* an instance name points to a target that is just the template name */
         if (streq(prefix, b))
-                return true;
+                return 1;
 
-        return false;
+        return 0;
 }
 
 static int process_deps(Unit *u, UnitDependency dependency, const char *dir_suffix) {
@@ -106,7 +106,12 @@ static int process_deps(Unit *u, UnitDependency dependency, const char *dir_suff
 
                 /* We don't treat this as an error, especially because we didn't check this for a
                  * long time. Nevertheless, we warn, because such mismatch can be mighty confusing. */
-                if (!unit_name_compatible(entry, basename(target)))
+                r = unit_name_compatible(entry, basename(target));
+                if (r < 0) {
+                        log_unit_warning_errno(u, r, "Can't check if names %s and %s are compatible, ignoring: %m", entry, basename(target));
+                        continue;
+                }
+                if (r == 0)
                         log_unit_warning(u, "%s dependency dropin %s target %s has different name",
                                          unit_dependency_to_string(dependency), *p, target);