git: 69d29fedc1bd - stable/15 - sys_procdesc: extract pdtofdflags()

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a812488.446db.71e8c31b__352.445994370498$1786848510$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by kib:

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

commit 69d29fedc1bd7f98796a00a8338d1c9555f4dc1e
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-05-20 02:03:32 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-08-16 02:41:20 +0000

    sys_procdesc: extract pdtofdflags()
    
    (cherry picked from commit 974770199877ae7aa912b6dced909429c52dea93)
---
 sys/kern/sys_procdesc.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c
index edf98b7f69d9..cb2d779df158 100644
--- a/sys/kern/sys_procdesc.c
+++ b/sys/kern/sys_procdesc.c
@@ -241,6 +241,17 @@ procdesc_new(struct proc *p, int flags)
 	p->p_procdesc = pd;
 }
 
+static int
+pdtofdflags(int flags)
+{
+	int fflags;
+
+	fflags = 0;
+	if (flags & PD_CLOEXEC)
+		fflags |= O_CLOEXEC;
+	return (fflags);
+}
+
 /*
  * Create a new process decriptor for the process that refers to it.
  */
@@ -248,13 +259,7 @@ int
 procdesc_falloc(struct thread *td, struct file **resultfp, int *resultfd,
     int flags, struct filecaps *fcaps)
 {
-	int fflags;
-
-	fflags = 0;
-	if (flags & PD_CLOEXEC)
-		fflags = O_CLOEXEC;
-
-	return (falloc_caps(td, resultfp, resultfd, fflags, fcaps));
+	return (falloc_caps(td, resultfp, resultfd, pdtofdflags(flags), fcaps));
 }
 
 /*
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.