On Tue, Sep 13, 2016 at 10:52:43PM +0200, Felix Fietkau wrote: > On 2016-09-13 16:25, Reiner Herrmann wrote: > > The counter is incremented during section allocation, but never > > decremented. > NACK. n_section is used for hashing only, decrementing it here probably > makes collisions for anonymous sections more likely.
I was encountering a strange behaviour related to adding/deleting sections, like in the example below. There I'm adding two sections, deleting one, commiting, deleting the other, and commiting again. I would expect that afterwards the package is empty and there is no diff in the save dir. But it is the case: $ uci -c /tmp/uci -X show foo.cfg0260ba=bar $ cat /tmp/.uci/foo -foo.cfg0460ba In a slightly more complex example the patch (decrementing the counter) seemed to help. Though with the minimal example from below, the issue also still exists... #include <uci.h> #include <string.h> int main() { struct uci_ptr ptr; struct uci_context *ctx = uci_alloc_context(); struct uci_section *section; uci_set_confdir(ctx, "/tmp/uci"); uci_lookup_ptr(ctx, &ptr, "foo", 0); /* Add two sections */ uci_add_section(ctx, ptr.p, "bar", §ion); uci_add_section(ctx, ptr.p, "bar", §ion); /* Delete one section */ uci_lookup_ptr(ctx, &ptr, strdup("foo.@bar[0]"), 1); uci_delete(ctx, &ptr); uci_save(ctx, ptr.p); uci_commit(ctx, &ptr.p, 1); /* Delete other section */ uci_lookup_ptr(ctx, &ptr, strdup("foo.@bar[0]"), 1); uci_delete(ctx, &ptr); uci_save(ctx, ptr.p); uci_commit(ctx, &ptr.p, 1); return 0; }
signature.asc
Description: Digital signature
_______________________________________________ Lede-dev mailing list Lede-dev@lists.infradead.org http://lists.infradead.org/mailman/listinfo/lede-dev