From a5eb996e0f04d911ff61479508bbc3e17b16ff0c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 19 Jan 2011 21:30:35 +0100 Subject: [PATCH 1/1] fix uci_list_set_pos to reorder sections properly, even when moving a section to the last position --- list.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/list.c b/list.c index a336b84..c8a4700 100644 --- 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) -- 2.11.0