From: Daniel Wagner <[email protected]>

---
 include/device.h    |    2 +-
 plugins/bluetooth.c |    6 ++----
 plugins/ethernet.c  |    5 +----
 plugins/ofono.c     |    5 ++---
 plugins/wifi.c      |   14 +++++++-------
 src/device.c        |    8 ++++----
 6 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/include/device.h b/include/device.h
index a82d08d..d4f54ec 100644
--- a/include/device.h
+++ b/include/device.h
@@ -88,7 +88,7 @@ int connman_device_add_network(struct connman_device *device,
 struct connman_network *connman_device_get_network(struct connman_device 
*device,
                                                        const char *identifier);
 int connman_device_remove_network(struct connman_device *device,
-                                                       const char *identifier);
+                                       struct connman_network *network);
 void connman_device_remove_all_networks(struct connman_device *device);
 
 void connman_device_schedule_scan(struct connman_device *device);
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index ccc5e9b..65a9d5d 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -549,7 +549,7 @@ static gboolean adapter_changed(DBusConnection *connection,
 static gboolean device_removed(DBusConnection *connection,
                                DBusMessage *message, void *user_data)
 {
-       const char *network_path, *identifier;
+       const char *network_path;
        struct connman_network *network;
        struct connman_device *device;
        DBusMessageIter iter;
@@ -569,11 +569,9 @@ static gboolean device_removed(DBusConnection *connection,
        if (device == NULL)
                return TRUE;
 
-       identifier = connman_network_get_identifier(network);
-
        g_hash_table_remove(bluetooth_networks, network_path);
 
-       connman_device_remove_network(device, identifier);
+       connman_device_remove_network(device, network);
 
        return TRUE;
 }
diff --git a/plugins/ethernet.c b/plugins/ethernet.c
index 5c02640..8295093 100644
--- a/plugins/ethernet.c
+++ b/plugins/ethernet.c
@@ -115,13 +115,10 @@ static void add_network(struct connman_device *device,
 static void remove_network(struct connman_device *device,
                                struct ethernet_data *ethernet)
 {
-       const char *identifier;
-
        if (ethernet->network == NULL)
                return;
 
-       identifier = connman_network_get_identifier(ethernet->network);
-       connman_device_remove_network(device, identifier);
+       connman_device_remove_network(device, ethernet->network);
        connman_network_unref(ethernet->network);
 
        ethernet->network = NULL;
diff --git a/plugins/ofono.c b/plugins/ofono.c
index 9cc48c6..c0deb9f 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -1739,7 +1739,7 @@ static gboolean context_removed(DBusConnection 
*connection,
                                DBusMessage *message, void *user_data)
 {
        const char *path = dbus_message_get_path(message);
-       const char *network_path, *identifier;
+       const char *network_path;
        struct modem_data *modem;
        struct network_info *info;
        DBusMessageIter iter;
@@ -1759,8 +1759,7 @@ static gboolean context_removed(DBusConnection 
*connection,
        if (info == NULL)
                return TRUE;
 
-       identifier = connman_network_get_identifier(info->network);
-       connman_device_remove_network(modem->device, identifier);
+       connman_device_remove_network(modem->device, info->network);
 
        return TRUE;
 }
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 8a7da09..edea4e7 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -831,15 +831,15 @@ static void network_removed(GSupplicantNetwork *network)
 
        DBG("name %s", name);
 
-       if (wifi != NULL) {
-               connman_network = connman_device_get_network(wifi->device, 
identifier);
-
-               connman_device_remove_network(wifi->device, identifier);
+       if (wifi == NULL)
+               return;
 
-               if (connman_network != NULL)
-                       connman_network_unref(connman_network);
+       connman_network = connman_device_get_network(wifi->device, identifier);
+       if (connman_network == NULL)
+               return;
 
-       }
+       connman_device_remove_network(wifi->device, connman_network);
+       connman_network_unref(connman_network);
 }
 
 static void debug(const char *str)
diff --git a/src/device.c b/src/device.c
index 87f503d..39c3fc0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1104,19 +1104,19 @@ struct connman_network 
*connman_device_get_network(struct connman_device *device
  * Remove network for given identifier
  */
 int connman_device_remove_network(struct connman_device *device,
-                                                       const char *identifier)
+                                               struct connman_network *network)
 {
-       struct connman_network *network;
        struct connman_service *service;
+       const char *identifier;
 
-       DBG("device %p identifier %s", device, identifier);
+       DBG("device %p network %p", device, network);
 
-       network = connman_device_get_network(device, identifier);
        if (network == NULL)
                return 0;
 
        service = __connman_service_lookup_from_network(network);
 
+       identifier = connman_network_get_identifier(network);
        g_hash_table_remove(device->networks, identifier);
 
        if (service != NULL)
-- 
1.7.6

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to