+ if (target->meta.type != UNIT_TARGET)
+ return 0;
+
+ /* Don't create loops */
+ if (set_get(target->meta.dependencies[UNIT_BEFORE], u))
+ return 0;
+
+ return unit_add_dependency(target, UNIT_AFTER, u, true);
+}
+
+static int unit_add_default_dependencies(Unit *u) {
+ Unit *other;
+ Iterator i;
+ int r;
+
+ assert(u);
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY], i)
+ if ((r = unit_add_one_default_dependency(u, other)) < 0)
+ return r;
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_REQUIRED_BY_OVERRIDABLE], i)
+ if ((r = unit_add_one_default_dependency(u, other)) < 0)
+ return r;
+
+ SET_FOREACH(other, u->meta.dependencies[UNIT_WANTED_BY], i)
+ if ((r = unit_add_one_default_dependency(u, other)) < 0)
+ return r;