]> pilppa.com Git - uci.git/commitdiff
fix uci_list_set_pos to reorder sections properly, even when moving a section to...
authorFelix Fietkau <nbd@openwrt.org>
Wed, 19 Jan 2011 20:30:35 +0000 (21:30 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 19 Jan 2011 20:30:35 +0000 (21:30 +0100)
list.c

diff --git a/list.c b/list.c
index a336b84aff7569223d1ec1c9546506df9aa7c5e7..c8a470055360c6b58592dd82a0d08943fc98e058 100644 (file)
--- a/list.c
+++ b/list.c
@@ -19,11 +19,12 @@ static void uci_list_set_pos(struct uci_list *head, struct uci_list *ptr, int po
 
        uci_list_del(ptr);
        uci_foreach_element(head, p) {
-               new_head = &p->list;
                if (pos-- <= 0)
                        break;
+               new_head = &p->list;
        }
-       uci_list_add(new_head, ptr);
+
+       uci_list_add(new_head->next, ptr);
 }
 
 static inline void uci_list_fixup(struct uci_list *ptr)