From f1828a222a7b4a859d90567f4721f31dd7536cd1 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 29 Sep 2020 21:43:59 +0900 Subject: [PATCH] network: make routing_policy_rule_new() static --- src/network/networkd-routing-policy-rule.c | 50 +++++++++++----------- src/network/networkd-routing-policy-rule.h | 3 -- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index 10b6a75cd7..386aa5789b 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -19,7 +19,32 @@ #include "strv.h" #include "user-util.h" -int routing_policy_rule_new(RoutingPolicyRule **ret) { +RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule) { + if (!rule) + return NULL; + + if (rule->network) { + assert(rule->section); + hashmap_remove(rule->network->rules_by_section, rule->section); + } + + if (rule->manager) { + if (set_get(rule->manager->rules, rule) == rule) + set_remove(rule->manager->rules, rule); + if (set_get(rule->manager->rules_foreign, rule) == rule) + set_remove(rule->manager->rules_foreign, rule); + } + + network_config_section_free(rule->section); + free(rule->iif); + free(rule->oif); + + return mfree(rule); +} + +DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free); + +static int routing_policy_rule_new(RoutingPolicyRule **ret) { RoutingPolicyRule *rule; rule = new(RoutingPolicyRule, 1); @@ -76,29 +101,6 @@ static int routing_policy_rule_new_static(Network *network, const char *filename return 0; } -RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule) { - if (!rule) - return NULL; - - if (rule->network) { - assert(rule->section); - hashmap_remove(rule->network->rules_by_section, rule->section); - } - - if (rule->manager) { - if (set_get(rule->manager->rules, rule) == rule) - set_remove(rule->manager->rules, rule); - if (set_get(rule->manager->rules_foreign, rule) == rule) - set_remove(rule->manager->rules_foreign, rule); - } - - network_config_section_free(rule->section); - free(rule->iif); - free(rule->oif); - - return mfree(rule); -} - static int routing_policy_rule_copy(RoutingPolicyRule *dest, RoutingPolicyRule *src) { _cleanup_free_ char *iif = NULL, *oif = NULL; diff --git a/src/network/networkd-routing-policy-rule.h b/src/network/networkd-routing-policy-rule.h index 1eaae2ec15..8510dec0fc 100644 --- a/src/network/networkd-routing-policy-rule.h +++ b/src/network/networkd-routing-policy-rule.h @@ -49,10 +49,7 @@ typedef struct RoutingPolicyRule { int suppress_prefixlen; } RoutingPolicyRule; -int routing_policy_rule_new(RoutingPolicyRule **ret); RoutingPolicyRule *routing_policy_rule_free(RoutingPolicyRule *rule); - -DEFINE_NETWORK_SECTION_FUNCTIONS(RoutingPolicyRule, routing_policy_rule_free); int routing_policy_rule_section_verify(RoutingPolicyRule *rule); int link_set_routing_policy_rules(Link *link); -- 2.25.1