From: Luca Boccassi Date: Wed, 9 Aug 2023 12:59:22 +0000 (+0100) Subject: core: allow to pass EINVAL to unit_add_two_dependencies() X-Git-Tag: v255-rc1~745^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ee8e9887a7e87174b5e25d61e13a58c08237c37;p=thirdparty%2Fsystemd.git core: allow to pass EINVAL to unit_add_two_dependencies() Useful to conditionally add two deps at a time --- diff --git a/src/core/unit.c b/src/core/unit.c index 6792bda9d01..0451a235099 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -3291,17 +3291,22 @@ int unit_add_dependency( } int unit_add_two_dependencies(Unit *u, UnitDependency d, UnitDependency e, Unit *other, bool add_reference, UnitDependencyMask mask) { - int r, s; + int r = 0, s = 0; assert(u); + assert(d >= 0 || e >= 0); - r = unit_add_dependency(u, d, other, add_reference, mask); - if (r < 0) - return r; + if (d >= 0) { + r = unit_add_dependency(u, d, other, add_reference, mask); + if (r < 0) + return r; + } - s = unit_add_dependency(u, e, other, add_reference, mask); - if (s < 0) - return s; + if (e >= 0) { + s = unit_add_dependency(u, e, other, add_reference, mask); + if (s < 0) + return s; + } return r > 0 || s > 0; }