git: 20ac5cda965e - main - fd: make fd/fp mandatory

Mateusz Guzik mjg at FreeBSD.org
Thu Jan 7 23:30:22 UTC 2021


The branch main has been updated by mjg:

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

commit 20ac5cda965eccc34f975674c6efc97c3615a234
Author:     Mateusz Guzik <mjg at FreeBSD.org>
AuthorDate: 2020-12-23 13:50:34 +0000
Commit:     Mateusz Guzik <mjg at FreeBSD.org>
CommitDate: 2021-01-07 23:30:04 +0000

    fd: make fd/fp mandatory
    
    They are both always passed anyway.
---
 sys/kern/kern_descrip.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index ff11ae4f1a61..e1ffdc3baf01 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1976,6 +1976,9 @@ falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, int flags,
 	struct file *fp;
 	int error, fd;
 
+	MPASS(resultfp != NULL);
+	MPASS(resultfd != NULL);
+
 	error = falloc_noinstall(td, &fp);
 	if (error)
 		return (error);		/* no reference held on error */
@@ -1986,13 +1989,8 @@ falloc_caps(struct thread *td, struct file **resultfp, int *resultfd, int flags,
 		return (error);
 	}
 
-	if (resultfp != NULL)
-		*resultfp = fp;		/* copy out result */
-	else
-		fdrop(fp, td);		/* release local reference */
-
-	if (resultfd != NULL)
-		*resultfd = fd;
+	*resultfp = fp;
+	*resultfd = fd;
 
 	return (0);
 }


More information about the dev-commits-src-all mailing list