Skip site navigation (1)Skip section navigation (2)


| raw e-mail | index | archive | help

The branch stable/13 has been updated by markj:

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

commit e2956be814a1ae86d7b5f83144b517e54424da27
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-13 23:26:49 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-11-17 14:29:25 +0000

    file: Simplify an INVARIANTS check in _fdrop()
    
    No functional change intended.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    
    (cherry picked from commit a2e22ed3420d92d9d98a1e9681b5c9b1fbe40fca)
---
 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 f51a1092114d..57ecf253f5be 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -3718,13 +3718,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);