Fix some coding style issues and make it more readable
authorMarcel Holtmann <marcel@holtmann.org>
Tue, 20 Oct 2009 20:20:50 +0000 (22:20 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 20 Oct 2009 20:20:50 +0000 (22:20 +0200)
src/element.c
src/inet.c
src/ipconfig.c

index c8ca76e..c5bac17 100644 (file)
@@ -1374,16 +1374,23 @@ static void register_element(gpointer data, gpointer user_data)
 
 gboolean __connman_element_device_isfiltered(const char *devname)
 {
-       if (device_filter != NULL &&
-                       g_pattern_match_simple(device_filter, devname) == FALSE) {
-               DBG("ignoring device %s (no match)", devname);
+       if (device_filter == NULL)
+               goto nodevice;
+
+       if (g_pattern_match_simple(device_filter, devname) == FALSE) {
+               DBG("ignoring device %s (match)", devname);
                return TRUE;
        }
-       if (nodevice_filter != NULL &&
-                       g_pattern_match_simple(nodevice_filter, devname) == TRUE) {
-               DBG("ignoring device %s (match no)", devname);
+
+nodevice:
+       if (nodevice_filter == NULL)
+               return FALSE;
+
+       if (g_pattern_match_simple(nodevice_filter, devname) == TRUE) {
+               DBG("ignoring device %s (no match)", devname);
                return TRUE;
        }
+
        return FALSE;
 }
 
@@ -1405,12 +1412,13 @@ int connman_element_register(struct connman_element *element,
        if (element->devname == NULL)
                element->devname = g_strdup(element->name);
 
-       if (element->type == CONNMAN_ELEMENT_TYPE_DEVICE &&
-                       __connman_element_device_isfiltered(element->devname) == TRUE) {
-               DBG("ignoring %s [%s] device", element->name, element->devname);
+        if (element->type != CONNMAN_ELEMENT_TYPE_DEVICE)
+               goto setup;
+
+       if (__connman_element_device_isfiltered(element->devname) == TRUE)
                return -EPERM;
-       }
 
+setup:
        if (connman_element_ref(element) == NULL)
                return -EINVAL;
 
index 7f4d139..ac68698 100644 (file)
@@ -441,9 +441,9 @@ struct connman_device *connman_inet_create_device(int index)
        devname = connman_inet_ifname(index);
        if (devname == NULL)
                return NULL;
+
        if (__connman_element_device_isfiltered(devname) == TRUE) {
-               connman_info("Ignoring network interface %s (filtered)",
-                   devname);
+               connman_info("Ignoring interface %s (filtered)", devname);
                return NULL;
        }
 
@@ -453,8 +453,7 @@ struct connman_device *connman_inet_create_device(int index)
 
        switch (type) {
        case CONNMAN_DEVICE_TYPE_UNKNOWN:
-               connman_info("Ignoring network interface %s (type unknown)",
-                   devname);
+               connman_info("Ignoring interface %s (type unknown)", devname);
                g_free(devname);
                return NULL;
        case CONNMAN_DEVICE_TYPE_ETHERNET:
index c18d36b..6212035 100644 (file)
@@ -304,9 +304,9 @@ void __connman_ipconfig_newlink(int index, unsigned short type,
                goto update;
 
        ifname = connman_inet_ifname(index);
+
        if (__connman_element_device_isfiltered(ifname) == TRUE) {
-               connman_info("Ignoring network interface %s (filtered)",
-                   ifname);
+               connman_info("Ignoring interface %s (filtered)", ifname);
                g_free(ifname);
                return;
        }