From e273ff4fe782df6a8e78c74315bb7c172a8fb545 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 29 Jul 2014 19:39:06 +0200 Subject: core: refactor nm_ip[46]_config_commit() not to make a copy of route In nm_ip4_config_commit() and nm_ip6_config_commit() there is no need to copy the route. Just use the pointer returned from nm_ip4_config_get_route()/ nm_ip6_config_get_route(). Signed-off-by: Thomas Haller --- src/nm-ip4-config.c | 12 ++++++------ src/nm-ip6-config.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index 62a6b19218..b286edb995 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -259,27 +259,27 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex) { int count = nm_ip4_config_get_num_routes (config); GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Route), count); - NMPlatformIP4Route route; + const NMPlatformIP4Route *route; gboolean success; for (i = 0; i < count; i++) { - memcpy (&route, nm_ip4_config_get_route (config, i), sizeof (route)); + route = nm_ip4_config_get_route (config, i); /* Don't add the route if it's more specific than one of the subnets * the device already has an IP address on. */ - if ( route.gateway == 0 - && nm_ip4_config_destination_is_direct (config, route.network, route.plen)) + if ( route->gateway == 0 + && nm_ip4_config_destination_is_direct (config, route->network, route->plen)) continue; /* Don't add the default route if the connection * is never supposed to be the default connection. */ if ( nm_ip4_config_get_never_default (config) - && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&route)) + && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) continue; - g_array_append_val (routes, route); + g_array_append_vals (routes, route, 1); } success = nm_platform_ip4_route_sync (ifindex, routes); diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 5012c57515..0d4307f288 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -371,26 +371,26 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex) { int count = nm_ip6_config_get_num_routes (config); GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP6Route), count); - NMPlatformIP6Route route; + const NMPlatformIP6Route *route; for (i = 0; i < count; i++) { - memcpy (&route, nm_ip6_config_get_route (config, i), sizeof (route)); + route = nm_ip6_config_get_route (config, i); /* Don't add the route if it's more specific than one of the subnets * the device already has an IP address on. */ - if ( IN6_IS_ADDR_UNSPECIFIED (&route.gateway) - && nm_ip6_config_destination_is_direct (config, &route.network, route.plen)) + if ( IN6_IS_ADDR_UNSPECIFIED (&route->gateway) + && nm_ip6_config_destination_is_direct (config, &route->network, route->plen)) continue; /* Don't add the default route if the connection * is never supposed to be the default connection. */ if ( nm_ip6_config_get_never_default (config) - && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (&route)) + && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (route)) continue; - g_array_append_val (routes, route); + g_array_append_vals (routes, route, 1); } success = nm_platform_ip6_route_sync (ifindex, routes); -- cgit v1.2.1