mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-28 11:55:23 +03:00
network: avoid temporary variables for parsing, use TAKE_PTR (#9166)
We don't need a temporary variable when parsing just one number, because our parsing functions do not touch the output variable on error. TAKE_PTR is more expressive than 'n = NULL'.
This commit is contained in:
parent
4dae3ef6c0
commit
aff4430136
@ -716,7 +716,7 @@ int config_parse_gateway(
|
||||
|
||||
n->family = f;
|
||||
n->gw = buffer;
|
||||
n = NULL;
|
||||
TAKE_PTR(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -757,7 +757,7 @@ int config_parse_preferred_src(
|
||||
|
||||
n->family = f;
|
||||
n->prefsrc = buffer;
|
||||
n = NULL;
|
||||
TAKE_PTR(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -813,8 +813,7 @@ int config_parse_destination(
|
||||
} else
|
||||
assert_not_reached(lvalue);
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -832,7 +831,6 @@ int config_parse_route_priority(
|
||||
|
||||
Network *network = userdata;
|
||||
_cleanup_(route_freep) Route *n = NULL;
|
||||
uint32_t k;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
@ -845,16 +843,14 @@ int config_parse_route_priority(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = safe_atou32(rvalue, &k);
|
||||
r = safe_atou32(rvalue, &n->priority);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Could not parse route priority \"%s\", ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
n->priority = k;
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -895,8 +891,7 @@ int config_parse_route_scope(
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -914,7 +909,6 @@ int config_parse_route_table(
|
||||
|
||||
_cleanup_(route_freep) Route *n = NULL;
|
||||
Network *network = userdata;
|
||||
uint32_t k;
|
||||
int r;
|
||||
|
||||
assert(filename);
|
||||
@ -927,16 +921,14 @@ int config_parse_route_table(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = safe_atou32(rvalue, &k);
|
||||
r = safe_atou32(rvalue, &n->table);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_ERR, filename, line, r,
|
||||
"Could not parse route table number \"%s\", ignoring assignment: %m", rvalue);
|
||||
return 0;
|
||||
}
|
||||
|
||||
n->table = k;
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -974,8 +966,7 @@ int config_parse_gateway_onlink(
|
||||
}
|
||||
|
||||
SET_FLAG(n->flags, RTNH_F_ONLINK, r);
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1010,8 +1001,7 @@ int config_parse_ipv6_route_preference(
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1049,8 +1039,7 @@ int config_parse_route_protocol(
|
||||
}
|
||||
}
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1087,8 +1076,7 @@ int config_parse_route_type(
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1135,8 +1123,7 @@ int config_parse_tcp_window(
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1173,8 +1160,7 @@ int config_parse_quickack(
|
||||
}
|
||||
|
||||
n->quickack = !!k;
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1208,7 +1194,6 @@ int config_parse_route_mtu(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
n = NULL;
|
||||
|
||||
TAKE_PTR(n);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user