svn commit: r230486 - head/sys/kern
Gleb Smirnoff
glebius at FreeBSD.org
Mon Jan 23 16:31:46 UTC 2012
Author: glebius
Date: Mon Jan 23 16:31:46 2012
New Revision: 230486
URL: http://svn.freebsd.org/changeset/base/230486
Log:
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.
Modified:
head/sys/kern/subr_hash.c
Modified: head/sys/kern/subr_hash.c
==============================================================================
--- head/sys/kern/subr_hash.c Mon Jan 23 16:28:35 2012 (r230485)
+++ head/sys/kern/subr_hash.c Mon Jan 23 16:31:46 2012 (r230486)
@@ -52,9 +52,7 @@ hashinit_flags(int elements, struct mall
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 mallo
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_ty
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)
More information about the svn-src-all
mailing list