diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-09 12:23:07 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-06-09 12:48:52 +0200 |
commit | 6923020ec12152ec9804d483de97284c970c7de3 (patch) | |
tree | 59ab45d72f42760508a1ae043f09a3a75ace6438 /src/network/networkd-routing-policy-rule.c | |
parent | update NEWS (diff) | |
download | systemd-6923020ec12152ec9804d483de97284c970c7de3.tar.xz systemd-6923020ec12152ec9804d483de97284c970c7de3.zip |
networkd: reorder conditional to handle errors first
This also avoid the implicit assumption that if r is not -ENOENT, 0, or 1,
it must be negative. The compiler cannot know this.
Diffstat (limited to 'src/network/networkd-routing-policy-rule.c')
-rw-r--r-- | src/network/networkd-routing-policy-rule.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index a319a6fbe3..39b773fcc0 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -338,7 +338,9 @@ static int routing_policy_rule_add(Manager *m, const RoutingPolicyRule *in, Rout rule->manager = m; existing = TAKE_PTR(rule); - } else if (r == 0) { + } else if (r < 0) + return r; + else if (r == 0) { /* Take over a foreign rule. */ r = set_ensure_put(&m->rules, &routing_policy_rule_hash_ops, existing); if (r < 0) @@ -346,11 +348,7 @@ static int routing_policy_rule_add(Manager *m, const RoutingPolicyRule *in, Rout assert(r > 0); set_remove(m->rules_foreign, existing); - } else if (r == 1) { - /* Already exists, do nothing. */ - ; - } else - return r; + } /* else r > 0: already exists, do nothing. */ if (ret) *ret = existing; |