FreeBSD/sys/kern/subr_unit.c
/*
 * Consistency check function.
 *
 * Checks the internal consistency as well as we can.
 * 
 * Called at all boundaries of this API.
 */
Consistency check function.
Checks the internal consistency as well as we can.

Called at all boundaries of this API.
Consistency check function . Checks the internal consistency as well as we can . Called at all boundaries of this API .
static void
check_unrhdr(struct unrhdr *uh, int line)
{
	struct unr *up;
	struct unrb *ub;
	int w;
	u_int y, z;
	y = uh->first;
	z = 0;
	TAILQ_FOREACH(up, &uh->head, list) {
		z++;
		if (up->ptr != uh && up->ptr != NULL) {
			ub = up->ptr;
			KASSERT (up->len <= NBITS,
			    ("UNR inconsistency: len %u max %zd (line %d)\n",
			    up->len, NBITS, line));
			z++;
			w = 0;
			bit_count(ub->map, 0, up->len, &w);
			y += w;
		} else if (up->ptr != NULL) 
			y += up->len;
	}
	KASSERT (y == uh->busy,
	    ("UNR inconsistency: items %u found %u (line %d)\n",
	    uh->busy, y, line));
	KASSERT (z == uh->alloc,
	    ("UNR inconsistency: chunks %u found %u (line %d)\n",
	    uh->alloc, z, line));
}
static void check_unrhdr ( struct unrhdr * uh , int line ) { struct unr * up ; struct unrb * ub ; int w ; u_int y , z ; y = uh -> first ; z = 0 ; TAILQ_FOREACH ( up , & uh -> head , list ) { z ++ ; if ( up -> ptr != uh && up -> ptr != NULL ) { ub = up -> ptr ; KASSERT ( up -> len <= NBITS , ( " \n " , up -> len , NBITS , line ) ) ; z ++ ; w = 0 ; bit_count ( ub -> map , 0 , up -> len , & w ) ; y += w ; } else if ( up -> ptr != NULL ) y += up -> len ; } KASSERT ( y == uh -> busy , ( " \n " , uh -> busy , y , line ) ) ; KASSERT ( z == uh -> alloc , ( " \n " , uh -> alloc , z , line ) ) ; }
Consistency check function.
Consistency check function .