From 02aeb23f1f1f9c9b0b6fdb5f66d1188c82b438b8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 8 Feb 2012 11:12:18 +0000 Subject: [PATCH] Use dm_list_iterate_items_safe And avoid direct access to list member variables. Inline _free_li(). --- WHATS_NEW | 1 + lib/label/label.c | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index e1c7182fd..07474e650 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.91 - =================================== + Use list functions for label_exit(). Ensure strncpy() function always ends with '\0'. Set status in _fsadm_cmd() for error path. Add missing deps for lvm2api for rebuild when lvm-internal is changed. diff --git a/lib/label/label.c b/lib/label/label.c index eb04ea359..f377367e1 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -56,11 +56,6 @@ static struct labeller_i *_alloc_li(const char *name, struct labeller *l) return li; } -static void _free_li(struct labeller_i *li) -{ - dm_free(li); -} - int label_init(void) { dm_list_init(&_labellers); @@ -69,14 +64,12 @@ int label_init(void) void label_exit(void) { - struct dm_list *c, *n; - struct labeller_i *li; + struct labeller_i *li, *tli; - for (c = _labellers.n; c && c != &_labellers; c = n) { - n = c->n; - li = dm_list_item(c, struct labeller_i); + dm_list_iterate_items_safe(li, tli, &_labellers) { + dm_list_del(&li->list); li->l->ops->destroy(li->l); - _free_li(li); + dm_free(li); } dm_list_init(&_labellers);