From f971def3c23d780aab99d988bd71b94931d74be6 Mon Sep 17 00:00:00 2001
From: Daan De Meyer <daan.j.demeyer@gmail.com>
Date: Thu, 12 May 2022 00:05:04 +0200
Subject: [PATCH] core: Return 1 from unit_add_dependency() on success

To allow checking if adding dependency was skipped or not.

Conflict:code context adaptation
Reference:https://github.com/systemd/systemd-stable/commit/f971def3c23d780aab99d988bd71b94931d74be6
---
 src/core/unit.c        | 2 +-
 src/test/test-engine.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/core/unit.c b/src/core/unit.c
index b0756bc6f4..fd95e02153 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -3146,7 +3146,7 @@ int unit_add_dependency(
         if (!noop)
                 unit_add_to_dbus_queue(u);
 
-        return 0;
+        return 1;
 }
 
 int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference, UnitDependencyMask mask) {
diff --git a/src/test/test-engine.c b/src/test/test-engine.c
index ef055360fb..d430076056 100644
--- a/src/test/test-engine.c
+++ b/src/test/test-engine.c
@@ -189,8 +189,8 @@ int main(int argc, char *argv[]) {
         assert_se(!hashmap_get(unit_get_dependencies(a, UNIT_PROPAGATES_RELOAD_TO), c));
         assert_se(!hashmap_get(unit_get_dependencies(c, UNIT_RELOAD_PROPAGATED_FROM), a));
 
-        assert_se(unit_add_dependency(a, UNIT_PROPAGATES_RELOAD_TO, b, true, UNIT_DEPENDENCY_UDEV) == 0);
-        assert_se(unit_add_dependency(a, UNIT_PROPAGATES_RELOAD_TO, c, true, UNIT_DEPENDENCY_PROC_SWAP) == 0);
+        assert_se(unit_add_dependency(a, UNIT_PROPAGATES_RELOAD_TO, b, true, UNIT_DEPENDENCY_UDEV) >= 0);
+        assert_se(unit_add_dependency(a, UNIT_PROPAGATES_RELOAD_TO, c, true, UNIT_DEPENDENCY_PROC_SWAP) >= 0);
 
         assert_se(hashmap_get(unit_get_dependencies(a, UNIT_PROPAGATES_RELOAD_TO), b));
         assert_se(hashmap_get(unit_get_dependencies(b, UNIT_RELOAD_PROPAGATED_FROM), a));
-- 
2.33.0

