From 2bd0506c8d94a2c581dd16407f3a1c159a38769b Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 1 May 2021 00:14:26 +0300 Subject: [PATCH] kern_ptrace: change type of proctree_locked to bool Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29955 --- sys/kern/sys_process.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 27a690e65638..492ef287ca53 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -612,13 +612,14 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) struct ptrace_lwpinfo *pl; struct ptrace_sc_ret *psr; int error, num, tmp; - int proctree_locked = 0; lwpid_t tid = 0, *buf; #ifdef COMPAT_FREEBSD32 int wrap32 = 0, safe = 0; #endif + bool proctree_locked; curp = td->td_proc; + proctree_locked = false; /* Lock proctree before locking the process. */ switch (req) { @@ -636,7 +637,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) case PT_DETACH: case PT_GET_SC_ARGS: sx_xlock(&proctree_lock); - proctree_locked = 1; + proctree_locked = true; break; default: break; @@ -816,7 +817,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) p->p_oppid); sx_xunlock(&proctree_lock); - proctree_locked = 0; + proctree_locked = false; MPASS(p->p_xthread == NULL); MPASS((p->p_flag & P_STOPPED_TRACE) == 0); @@ -1053,10 +1054,10 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) } sx_xunlock(&proctree_lock); - proctree_locked = 0; + proctree_locked = false; sendsig: - MPASS(proctree_locked == 0); + MPASS(!proctree_locked); /* * Clear the pending event for the thread that just