diff options
author | Felix Fietkau <nbd@pi.lan> | 2008-08-23 13:36:39 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@pi.lan> | 2008-08-23 13:36:39 +0200 |
commit | 6ae6536eddd7605135a5e18c92fefc3e442943bd (patch) | |
tree | 2efee6655005ba6df8ce43148a788a9127243e0a | |
parent | 3b7f28bf504d575555aac3c71343976650029042 (diff) | |
download | uci-6ae6536eddd7605135a5e18c92fefc3e442943bd.tar.gz |
filter out duplicate changes when using uci_set to change option values
-rw-r--r-- | list.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -620,6 +620,12 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr) UCI_ASSERT(ctx, uci_validate_str(ptr->value, false)); } + if (!ptr->o && ptr->s && ptr->option) { + struct uci_element *e; + e = uci_lookup_list(&ptr->s->options, ptr->option); + if (e) + ptr->o = uci_to_option(e); + } if (!ptr->o && ptr->option) { /* new option */ ptr->o = uci_alloc_option(ptr->s, ptr->option, ptr->value); ptr->last = &ptr->o->e; @@ -627,6 +633,9 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr) ptr->s = uci_alloc_section(ptr->p, ptr->value, ptr->section); ptr->last = &ptr->s->e; } else if (ptr->o && ptr->option) { /* update option */ + if ((ptr->o->type == UCI_TYPE_STRING) && + !strcmp(ptr->o->v.string, ptr->value)) + return 0; uci_free_option(ptr->o); ptr->o = uci_alloc_option(ptr->s, ptr->option, ptr->value); ptr->last = &ptr->o->e; |