diff options
| author | tkusumi <tkusumi@NetBSD.org> | 2019-12-07 06:26:31 +0000 |
|---|---|---|
| committer | tkusumi <tkusumi@NetBSD.org> | 2019-12-07 06:26:31 +0000 |
| commit | 717f3b97986b7f052707938883f4bb1da0133add (patch) | |
| tree | afc1a7cf9296a8a3b45d60e9ce179e6fbd74c2d1 /sys/dev/dm/dm_table.c | |
| parent | af0b6d79f13199d776c819de85663264bba0a12f (diff) | |
dm: Simplify list eviction code
taken-from: DragonFlyBSD
Diffstat (limited to 'sys/dev/dm/dm_table.c')
| -rw-r--r-- | sys/dev/dm/dm_table.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/dev/dm/dm_table.c b/sys/dev/dm/dm_table.c index 54021558725..47bbece0f51 100644 --- a/sys/dev/dm/dm_table.c +++ b/sys/dev/dm/dm_table.c @@ -1,4 +1,4 @@ -/* $NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $ */ +/* $NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.10 2019/12/05 16:59:43 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dm_table.c,v 1.11 2019/12/07 06:26:31 tkusumi Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -160,15 +160,14 @@ dm_table_destroy(dm_table_head_t * head, uint8_t table_id) tbl = &head->tables[id]; - while (!SLIST_EMPTY(tbl)) { /* List Deletion. */ - table_en = SLIST_FIRST(tbl); + while ((table_en = SLIST_FIRST(tbl)) != NULL) { + SLIST_REMOVE(tbl, table_en, dm_table_entry, next); if (table_en->target->destroy(table_en) == 0) table_en->target_config = NULL; - SLIST_REMOVE_HEAD(tbl, next); - kmem_free(table_en, sizeof(*table_en)); } + KASSERT(SLIST_EMPTY(tbl)); mutex_exit(&head->table_mtx); |
