network: minor coding style update
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Feb 2019 12:25:13 +0000 (21:25 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 15 Feb 2019 01:23:40 +0000 (10:23 +0900)
src/network/networkd-dhcp4.c

index d8ac455..ea5dab3 100644 (file)
@@ -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;