kern/subr_unit.c: more uses for is_bitmap()

To facilitate it, move the is_bitmap() definition earlier.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40089
This commit is contained in:
Konstantin Belousov 2023-05-13 01:39:35 +03:00
parent 042ec55f9d
commit 36b1f8a81e

View file

@ -194,6 +194,12 @@ CTASSERT((sizeof(struct unr) % sizeof(bitstr_t)) == 0);
/* Number of bits we can store in the bitmap */
#define NBITS (NBBY * sizeof(((struct unrb *)NULL)->map))
static inline bool
is_bitmap(struct unrhdr *uh, struct unr *up)
{
return (up->ptr != uh && up->ptr != NULL);
}
/* Is the unrb empty in at least the first len bits? */
static inline bool
ub_empty(struct unrb *ub, int len) {
@ -233,7 +239,7 @@ check_unrhdr(struct unrhdr *uh, int line)
z = 0;
TAILQ_FOREACH(up, &uh->head, list) {
z++;
if (up->ptr != uh && up->ptr != NULL) {
if (is_bitmap(uh, up)) {
ub = up->ptr;
KASSERT (up->len <= NBITS,
("UNR inconsistency: len %u max %zd (line %d)\n",
@ -396,12 +402,6 @@ clear_unrhdr(struct unrhdr *uh)
check_unrhdr(uh, __LINE__);
}
static __inline int
is_bitmap(struct unrhdr *uh, struct unr *up)
{
return (up->ptr != uh && up->ptr != NULL);
}
/*
* Look for sequence of items which can be combined into a bitmap, if
* multiple are present, take the one which saves most memory.