summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_hash.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-01-23 16:31:46 +0000
committerglebius <glebius@FreeBSD.org>2012-01-23 16:31:46 +0000
commit18321230d6cae24968b5414a59466336822cc449 (patch)
tree91ccdb60669a9c1913037b430dbb0457e5926548 /sys/kern/subr_hash.c
parent4fad17c424a2704e42c615adbaefb5e991119dec (diff)
downloadFreeBSD-src-18321230d6cae24968b5414a59466336822cc449.zip
FreeBSD-src-18321230d6cae24968b5414a59466336822cc449.tar.gz
Convert panic()s to KASSERT()s. This is an optimisation for
hashdestroy() since in absence of INVARIANTS a compiler will drop the entire for() cycle.
Diffstat (limited to 'sys/kern/subr_hash.c')
-rw-r--r--sys/kern/subr_hash.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sys/kern/subr_hash.c b/sys/kern/subr_hash.c
index 8ffbc9c..5533882 100644
--- a/sys/kern/subr_hash.c
+++ b/sys/kern/subr_hash.c
@@ -52,9 +52,7 @@ hashinit_flags(int elements, struct malloc_type *type, u_long *hashmask,
LIST_HEAD(generic, generic) *hashtbl;
int i;
- if (elements <= 0)
- panic("hashinit: bad elements");
-
+ KASSERT(elements > 0, ("%s: bad elements", __func__));
/* Exactly one of HASH_WAITOK and HASH_NOWAIT must be set. */
KASSERT((flags & HASH_WAITOK) ^ (flags & HASH_NOWAIT),
("Bad flags (0x%x) passed to hashinit_flags", flags));
@@ -95,8 +93,7 @@ hashdestroy(void *vhashtbl, struct malloc_type *type, u_long hashmask)
hashtbl = vhashtbl;
for (hp = hashtbl; hp <= &hashtbl[hashmask]; hp++)
- if (!LIST_EMPTY(hp))
- panic("hashdestroy: hash not empty");
+ KASSERT(LIST_EMPTY(hp), ("%s: hash not empty", __func__));
free(hashtbl, type);
}
@@ -115,8 +112,7 @@ phashinit(int elements, struct malloc_type *type, u_long *nentries)
LIST_HEAD(generic, generic) *hashtbl;
int i;
- if (elements <= 0)
- panic("phashinit: bad elements");
+ KASSERT(elements > 0, ("%s: bad elements", __func__));
for (i = 1, hashsize = primes[1]; hashsize <= elements;) {
i++;
if (i == NPRIMES)
OpenPOWER on IntegriCloud