From 0e24f4771d29aa6e70d13f3d815072f9aa85ccf8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fl=C3=A1vio=20Ceolin?= Date: Thu, 29 Dec 2011 15:48:40 -0200 Subject: [PATCH] iptables: Small improvements on ipatables_init() 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 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/iptables.c b/src/iptables.c index 9d6a9e7..807f22c 100644 --- a/src/iptables.c +++ b/src/iptables.c @@ -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; -- 2.7.4