Mercurial > libjeffpc
changeset 773:3e2779bb68a0
synch: move mutex destroy checking into a helper function
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Sun, 11 Aug 2019 11:59:45 -0400 |
parents | f2c96ac96787 |
children | e05fd965c1ba |
files | synch.c |
diffstat | 1 files changed, 19 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/synch.c Thu Jul 25 14:21:54 2019 -0400 +++ b/synch.c Sun Aug 11 11:59:45 2019 -0400 @@ -545,6 +545,24 @@ #endif } +static void check_unheld_for_destroy(struct lock_info *info, + const struct lock_context *where) +{ +#ifdef JEFFPC_LOCK_TRACKING + struct held_lock *held; + size_t i; + + /* check that we're not holding it */ + for_each_held_lock(i, held) { + if (held->info != info) + continue; + + error_destroy(held, where); + return; + } +#endif +} + static void verify_lock_init(const struct lock_context *where, struct lock *l, struct lock_class *lc) { @@ -566,22 +584,7 @@ print_invalid_call("MXDESTROY", where); check_magic(&l->info, "destroy", where, SYNCH_TYPE_MUTEX); - -#ifdef JEFFPC_LOCK_TRACKING - struct held_lock *held; - size_t i; - - /* check that we're not holding it */ - for_each_held_lock(i, held) { - if (held->info != &l->info) - continue; - - sanity_check_held_synch_type(held, SYNCH_TYPE_MUTEX); - - error_destroy(held, where); - return; - } -#endif + check_unheld_for_destroy(&l->info, where); l->info.magic = DESTROYED_MAGIC; /* keep the synch type set to aid debugging */