| 1 | From: Felix Fietkau <nbd@openwrt.org> |
| 2 | Date: Wed, 19 Jan 2011 20:30:35 +0000 (+0100) |
| 3 | Subject: fix uci_list_set_pos to reorder sections properly, even when moving a section to ... |
| 4 | X-Git-Url: http://nbd.name/gitweb.cgi?p=uci.git;a=commitdiff_plain;h=a5eb996e0f04d911ff61479508bbc3e17b16ff0c |
| 5 | |
| 6 | fix uci_list_set_pos to reorder sections properly, even when moving a section to the last position |
| 7 | --- |
| 8 | |
| 9 | --- a/list.c |
| 10 | +++ b/list.c |
| 11 | @@ -55,11 +55,12 @@ static inline void uci_list_set_pos(stru |
| 12 | |
| 13 | uci_list_del(ptr); |
| 14 | uci_foreach_element(head, p) { |
| 15 | - new_head = &p->list; |
| 16 | if (pos-- <= 0) |
| 17 | break; |
| 18 | + new_head = &p->list; |
| 19 | } |
| 20 | - uci_list_add(new_head, ptr); |
| 21 | + |
| 22 | + uci_list_add(new_head->next, ptr); |
| 23 | } |
| 24 | |
| 25 | static inline void uci_list_fixup(struct uci_list *ptr) |
| 26 | |