On 03/08/2013 09:09 AM, Tomasz Bursztyka wrote:
Le 07/03/2013 15:35, Daniel Wagner a écrit :
-    /* We have deleted a rule,
-     * all references should be bumped accordingly */
+    /*
+     * We have deleted a rule, all references should be bumped
+     * accordingly
+     */

What an improvement ;]
Just kidding.

Just made the comment consistent with the rest :)

Seriously, here again I don't see it clarifies the code more.
Actually, only the comments you added do clarify things, these are
relevant yes!

Have you looked at the result? For example

iptables_delete_rule():

BEFORE:

     /* We have deleted a rule,
         * all references should be bumped accordingly */
        if (list->next != NULL)
                update_targets_reference(table, list->next->data,
                                                list->data, TRUE);

        removed += remove_table_entry(table, entry);

        if (builtin >= 0) {
                list = list->next;
                if (list) {
                        entry = list->data;
                        entry->builtin = builtin;
                }

                table->underflow[builtin] -= removed;
                for (list = chain_tail; list; list = list->next) {
                        entry = list->data;

                        builtin = entry->builtin;
                        if (builtin < 0)
                                continue;

                        table->hook_entry[builtin] -= removed;
                        table->underflow[builtin] -= removed;
                }
        }

        update_offsets(table);


AFTER:

        /*
         * We have deleted a rule, all references should be bumped
         * accordingly
         */
        if (list->next != NULL)
                update_targets_reference(table, list->next->data,
                                                list->data, TRUE);

        removed += remove_table_entry(table, list->data);

        /*
         * We need to update the hooks if the rule was part of a built
         * in chain.
         */
        entry = chain_head->data;
        if (entry->builtin >= 0)
                delete_update_hooks(table, chain_head, removed);

        update_offsets(table);



And then I just realized that in iptables_flush_chain() the exact open coded update function exists:


        if (builtin >= 0) {
                struct connman_iptables_entry *e;

                entry = list->data;

                entry->builtin = builtin;

                table->underflow[builtin] -= removed;

                for (list = chain_tail; list; list = list->next) {
                        e = list->data;

                        builtin = e->builtin;
                        if (builtin < 0)
                                continue;

                        table->hook_entry[builtin] -= removed;
                        table->underflow[builtin] -= removed;
                }
        }

        update_offsets(table);

And please don't tell me now, code duplication is okay.

I really hope you start understanding my effort here. I am not trying to break stuff. I want to improve the code and I believe the patches _do_ improve the situation. All the comments are the result from the refactoring. Please take the time to look at the result not just at the patch.

cheers,
daniel

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

Reply via email to