From 860e636cf6855260634ef2f7f52af4635b1271c3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 11 Feb 2019 21:25:13 +0900 Subject: [PATCH] network: minor coding style update --- src/network/networkd-dhcp4.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index d8ac455..ea5dab3 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -70,7 +70,7 @@ static int link_set_dhcp_routes(Link *link) { /* When the interface is part of an VRF use the VRFs routing table, unless * there is a another table specified. */ table = link->network->dhcp_route_table; - if (!link->network->dhcp_route_table_set && link->network->vrf != NULL) + if (!link->network->dhcp_route_table_set && link->network->vrf) table = VRF(link->network->vrf)->table; r = sd_dhcp_lease_get_address(link->dhcp_lease, &address); @@ -135,14 +135,7 @@ static int link_set_dhcp_routes(Link *link) { log_link_warning(link, "Classless static routes received from DHCP server: ignoring static-route option and router option"); if (r >= 0 && !classless_route) { - _cleanup_(route_freep) Route *route = NULL; - _cleanup_(route_freep) Route *route_gw = NULL; - - r = route_new(&route); - if (r < 0) - return log_link_error_errno(link, r, "Could not allocate route: %m"); - - route->protocol = RTPROT_DHCP; + _cleanup_(route_freep) Route *route = NULL, *route_gw = NULL; r = route_new(&route_gw); if (r < 0) @@ -166,9 +159,14 @@ static int link_set_dhcp_routes(Link *link) { link->dhcp4_messages++; + r = route_new(&route); + if (r < 0) + return log_link_error_errno(link, r, "Could not allocate route: %m"); + route->family = AF_INET; route->gw.in = gateway; route->prefsrc.in = address; + route->protocol = RTPROT_DHCP; route->priority = link->network->dhcp_route_metric; route->table = table; -- 2.7.4