+/* fix up option list HEAD pointers and pointer to section in options */
+static void uci_section_fixup_options(struct uci_section *s, bool no_options)
+{
+ struct uci_element *e;
+
+ if (no_options) {
+ /*
+ * enforce empty list pointer state (s->next == s) when original
+ * section had no options in the first place
+ */
+ uci_list_init(&s->options);
+ return;
+ }
+
+ /* fix pointers to HEAD at end/beginning of list */
+ uci_list_fixup(&s->options);
+
+ /* fix back pointer to section in options */
+ uci_foreach_element(&s->options, e) {
+ struct uci_option *o;
+
+ o = uci_to_option(e);
+ o->section = s;
+ }
+}
+