mirror of
https://github.com/systemd/systemd.git
synced 2025-02-15 09:57:39 +03:00
network: reduce scope of variables
This commit is contained in:
parent
ddc9df3183
commit
eb3445ce93
@ -611,13 +611,15 @@ static bool manager_links_have_routing_policy_rule(Manager *m, RoutingPolicyRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void routing_policy_rule_purge(Manager *m, Link *link) {
|
static void routing_policy_rule_purge(Manager *m, Link *link) {
|
||||||
RoutingPolicyRule *rule, *existing;
|
RoutingPolicyRule *rule;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
assert(link);
|
assert(link);
|
||||||
|
|
||||||
SET_FOREACH(rule, m->rules_saved) {
|
SET_FOREACH(rule, m->rules_saved) {
|
||||||
|
RoutingPolicyRule *existing;
|
||||||
|
|
||||||
existing = set_get(m->rules_foreign, rule);
|
existing = set_get(m->rules_foreign, rule);
|
||||||
if (!existing)
|
if (!existing)
|
||||||
continue; /* Saved rule does not exist anymore. */
|
continue; /* Saved rule does not exist anymore. */
|
||||||
@ -1258,13 +1260,12 @@ int routing_policy_rule_section_verify(RoutingPolicyRule *rule) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int routing_policy_serialize_rules(Set *rules, FILE *f) {
|
int routing_policy_serialize_rules(Set *rules, FILE *f) {
|
||||||
RoutingPolicyRule *rule = NULL;
|
RoutingPolicyRule *rule;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(f);
|
assert(f);
|
||||||
|
|
||||||
SET_FOREACH(rule, rules) {
|
SET_FOREACH(rule, rules) {
|
||||||
_cleanup_free_ char *from_str = NULL, *to_str = NULL;
|
|
||||||
const char *family_str;
|
const char *family_str;
|
||||||
bool space = false;
|
bool space = false;
|
||||||
|
|
||||||
@ -1278,24 +1279,28 @@ int routing_policy_serialize_rules(Set *rules, FILE *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!in_addr_is_null(rule->family, &rule->from)) {
|
if (!in_addr_is_null(rule->family, &rule->from)) {
|
||||||
r = in_addr_to_string(rule->family, &rule->from, &from_str);
|
_cleanup_free_ char *str = NULL;
|
||||||
|
|
||||||
|
r = in_addr_to_string(rule->family, &rule->from, &str);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
fprintf(f, "%sfrom=%s/%hhu",
|
fprintf(f, "%sfrom=%s/%hhu",
|
||||||
space ? " " : "",
|
space ? " " : "",
|
||||||
from_str, rule->from_prefixlen);
|
str, rule->from_prefixlen);
|
||||||
space = true;
|
space = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_addr_is_null(rule->family, &rule->to)) {
|
if (!in_addr_is_null(rule->family, &rule->to)) {
|
||||||
r = in_addr_to_string(rule->family, &rule->to, &to_str);
|
_cleanup_free_ char *str = NULL;
|
||||||
|
|
||||||
|
r = in_addr_to_string(rule->family, &rule->to, &str);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
fprintf(f, "%sto=%s/%hhu",
|
fprintf(f, "%sto=%s/%hhu",
|
||||||
space ? " " : "",
|
space ? " " : "",
|
||||||
to_str, rule->to_prefixlen);
|
str, rule->to_prefixlen);
|
||||||
space = true;
|
space = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user