git: 36b1f8a81ef9 - main - kern/subr_unit.c: more uses for is_bitmap()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 29 May 2023 22:11:19 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=36b1f8a81ef96b42ce446efb79cffd577f1819f7

commit 36b1f8a81ef96b42ce446efb79cffd577f1819f7
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-05-12 22:39:35 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-05-29 22:10:35 +0000

    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
---
 sys/kern/subr_unit.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/kern/subr_unit.c b/sys/kern/subr_unit.c
index 22710f546d4f..a1878ea4b144 100644
--- a/sys/kern/subr_unit.c
+++ b/sys/kern/subr_unit.c
@@ -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.