git: 001fc46caa54 - stable/14 - file: Simplify an INVARIANTS check in _fdrop()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 01 Jun 2025 19:54:02 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=001fc46caa5469c1693f5f64c801815cb0dedbf1
commit 001fc46caa5469c1693f5f64c801815cb0dedbf1
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-13 23:26:49 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-06-01 19:53:29 +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 2d1c0d4aea5f..56e8a14f71b3 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -3701,13 +3701,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);