iptables: Small improvements on ipatables_init()
authorFlávio Ceolin <flavio.ceolin@profusion.mobi>
Thu, 29 Dec 2011 17:48:40 +0000 (15:48 -0200)
committerDaniel Wagner <daniel.wagner@bmw-carit.de>
Thu, 5 Jan 2012 10:06:34 +0000 (11:06 +0100)
Just returning NULL instead of go to "err:" when
"table" is NULL, also removing a duplicated
 g_free(module).

It's avoiding, at least, a "goto" + "g_free()" +
"table_cleanup()".

src/iptables.c

index 9d6a9e7..807f22c 100644 (file)
@@ -1176,17 +1176,18 @@ static struct connman_iptables *iptables_init(char *table_name)
        DBG("%s", table_name);
 
        if (xtables_insmod("ip_tables", NULL, TRUE) != 0)
-               goto err;
+               return NULL;
 
        module = g_strconcat("iptable_", table_name, NULL);
        if (module == NULL)
-               goto err;
+               return NULL;
 
-       if (xtables_insmod(module, NULL, TRUE) != 0)
-               goto err;
+       if (xtables_insmod(module, NULL, TRUE) != 0) {
+               g_free(module);
+               return NULL;
+       }
 
        g_free(module);
-       module = NULL;
 
        table = g_hash_table_lookup(table_hash, table_name);
        if (table != NULL)
@@ -1239,8 +1240,6 @@ static struct connman_iptables *iptables_init(char *table_name)
        return table;
 
 err:
-       g_free(module);
-
        table_cleanup(table);
 
        return NULL;