service: Simplify nameserver route adding and removing
[framework/connectivity/connman.git] / plugins / ofono.c
index 5585f44..ae419be 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Connection Manager
  *
- *  Copyright (C) 2007-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2007-2012  Intel Corporation. All rights reserved.
  *  Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
  *  Copyright (C) 2011  BWM Car IT GmbH. All rights reserved.
  *
@@ -43,8 +43,6 @@
 
 #include "mcc.h"
 
-#define uninitialized_var(x) x = x
-
 #define OFONO_SERVICE                  "org.ofono"
 
 #define OFONO_MANAGER_INTERFACE                OFONO_SERVICE ".Manager"
@@ -834,7 +832,7 @@ static void extract_ipv6_settings(DBusMessageIter *array,
 {
        DBusMessageIter dict;
        char *address = NULL, *gateway = NULL;
-       unsigned char prefix_length;
+       unsigned char prefix_length = 0;
        char *nameservers = NULL;
        const char *interface = NULL;
        int index = -1;
@@ -937,7 +935,7 @@ static connman_bool_t ready_to_create_device(struct modem_data *modem)
 static void create_device(struct modem_data *modem)
 {
        struct connman_device *device;
-       char *uninitialized_var(ident);
+       char *ident = NULL;
 
        DBG("%s", modem->path);
 
@@ -1062,7 +1060,7 @@ static void remove_network(struct modem_data *modem)
 static int add_cm_context(struct modem_data *modem, const char *context_path,
                                DBusMessageIter *dict)
 {
-       const char *context_type;
+       const char *context_type = NULL;
        struct network_context *context = NULL;
        connman_bool_t active = FALSE;
 
@@ -1131,7 +1129,7 @@ static int add_cm_context(struct modem_data *modem, const char *context_path,
 
        g_hash_table_replace(context_hash, g_strdup(context_path), modem);
 
-       if (modem->valid_apn == TRUE &&
+       if (modem->valid_apn == TRUE && modem->attached == TRUE &&
                        has_interface(modem->interfaces,
                                OFONO_API_NETREG) == TRUE) {
                add_network(modem);
@@ -1218,6 +1216,9 @@ static gboolean context_changed(DBusConnection *connection,
                        if (modem->network != NULL)
                                return TRUE;
 
+                       if (modem->attached == FALSE)
+                               return TRUE;
+
                        if (has_interface(modem->interfaces,
                                        OFONO_API_NETREG) == FALSE) {
                                return TRUE;