]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: make routing_policy_rule_new() static
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 29 Sep 2020 12:43:59 +0000 (21:43 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:36:29 +0000 (02:36 +0900)
src/network/networkd-routing-policy-rule.c
src/network/networkd-routing-policy-rule.h

index 10b6a75cd784b4291c53e450ec9a17142f9423e1..386aa5789b0a38e1780952ffcd14729431a720b3 100644 (file)
 #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;
 
index 1eaae2ec15b7fdd3efb5df4dea2adfd3d69f165e..8510dec0fc2b5a0b3466014a1f52e2389c800d1e 100644 (file)
@@ -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);