---
Hi, here is a small patch to eliminate duplicate code in find_chain_tail: it 
actually is a perfect copy 
of find_chain_head at the beginning. So this patch uses find_chain_head instead.

Please review,

Tomasz 

 src/iptables.c |   24 +++---------------------
 1 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/src/iptables.c b/src/iptables.c
index e852e01..d5555f9 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -243,33 +243,15 @@ static GList *find_chain_tail(struct connman_iptables 
*table,
                                char *chain_name)
 {
        GList *chain_head, *list;
-       struct connman_iptables_entry *head, *tail;
+       struct connman_iptables_entry *tail;
        struct ipt_entry *entry;
-       struct xt_entry_target *target;
-       int builtin;
 
        /* First we look for the head */
-       for (list = table->entries; list; list = list->next) {
-               head = list->data;
-               entry = head->entry;
-
-               /* Buit-in chain */
-               builtin = head->builtin;
-               if (builtin >= 0 && !strcmp(hooknames[builtin], chain_name))
-                       break;
-
-               /* User defined chain */
-               target = ipt_get_target(entry);
-               if (!strcmp(target->u.user.name, IPT_ERROR_TARGET) &&
-                   !strcmp((char *)target->data, chain_name))
-                       break;
-       }
+       chain_head = find_chain_head(table, chain_name);
 
-       if (list == NULL)
+       if (chain_head == NULL)
                return NULL;
 
-       chain_head = list;
-
        /* Then we look for the next chain */
        for (list = chain_head->next; list; list = list->next) {
                tail = list->data;
-- 
1.7.3.4

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

Reply via email to