summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-03 04:18:23 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-06-03 11:18:23 +0900
commitaff443013640ba783c89c9032ebd5a557f2fc11e (patch)
tree44f0c03115d15efd97957979e6ce823906f47797 /src
parent4dae3ef6c0afebcfd06d1125a18faa06f516841f (diff)
downloadsystemd-aff443013640ba783c89c9032ebd5a557f2fc11e.tar.gz
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'.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-route.c45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index a5303dafa1..369e453428 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -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;
}