git: a2e22ed3420d - main - file: Simplify an INVARIANTS check in _fdrop()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 13 May 2025 23:33:43 UTC
The branch main has been updated by markj:

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

commit a2e22ed3420d92d9d98a1e9681b5c9b1fbe40fca
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-13 23:26:49 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-13 23:27:19 +0000

    file: Simplify an INVARIANTS check in _fdrop()
    
    No functional change intended.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
---
 sys/kern/kern_descrip.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index f007b22f90ec..cbffe592554d 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -3699,13 +3699,10 @@ int __noinline
 _fdrop(struct file *fp, struct thread *td)
 {
 	int error;
-#ifdef INVARIANTS
-	int count;
 
-	count = refcount_load(&fp->f_count);
-	if (count != 0)
-		panic("fdrop: fp %p count %d", fp, count);
-#endif
+	KASSERT(refcount_load(&fp->f_count) == 0,
+	    ("fdrop: fp %p count %d", fp, refcount_load(&fp->f_count)));
+
 	error = fo_close(fp, td);
 	atomic_subtract_int(&openfiles, 1);
 	crfree(fp->f_cred);