Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
return ret;
}
+static void free_lease(struct lease *l)
+{
+ if (l->head.next)
+ list_del(&l->head);
+
+ free(l->duid);
+ free(l);
+}
+
static struct interface* get_interface(const char *name)
{
struct interface *c;
return 0;
err:
- if (lease) {
- free(lease->duid);
- free(lease);
- }
+ if (lease)
+ free_lease(lease);
+
return -1;
}
{
struct uci_context *uci = uci_alloc_context();
- while (!list_empty(&leases)) {
- struct lease *l = list_first_entry(&leases, struct lease, head);
- list_del(&l->head);
- free(l->duid);
- free(l);
- }
+ while (!list_empty(&leases))
+ free_lease(list_first_entry(&leases, struct lease, head));
struct interface *master = NULL, *i, *n;