[PATCH 1/3] nm-ip[64]-config: check return value from nm_platform_ip[64]_address_sync()



Signed-off-by: David Ward <david ward ll mit edu>
---
 src/nm-ip4-config.c | 10 +++++-----
 src/nm-ip6-config.c |  4 +++-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c
index abc8af8..bd99961 100644
--- a/src/nm-ip4-config.c
+++ b/src/nm-ip4-config.c
@@ -265,19 +265,21 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
 {
        NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
        int i;
+       gboolean success;
 
        g_return_val_if_fail (ifindex > 0, FALSE);
        g_return_val_if_fail (config != NULL, FALSE);
 
        /* Addresses */
-       nm_platform_ip4_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, default_route_metric);
+       success = nm_platform_ip4_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, 
default_route_metric);
+       if (!success)
+               return FALSE;
 
        /* Routes */
        {
                int count = nm_ip4_config_get_num_routes (config);
                GArray *routes = g_array_sized_new (FALSE, FALSE, sizeof (NMPlatformIP4Route), count);
                const NMPlatformIP4Route *route;
-               gboolean success;
 
                for (i = 0; i < count; i++) {
                        route = nm_ip4_config_get_route (config, i);
@@ -294,11 +296,9 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
 
                success = nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
                g_array_unref (routes);
-               if (!success)
-                       return FALSE;
        }
 
-       return TRUE;
+       return success;
 }
 
 void
diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c
index 9d4bf47..56ce981 100644
--- a/src/nm-ip6-config.c
+++ b/src/nm-ip6-config.c
@@ -387,7 +387,9 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
        g_return_val_if_fail (config != NULL, FALSE);
 
        /* Addresses */
-       nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE);
+       success = nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE);
+       if (!success)
+               return FALSE;
 
        /* Routes */
        {
-- 
1.8.3.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]