cygwin: Remove comparison of 'this' to NULL in _pinfo::exists

Fix all callers.
This commit is contained in:
Ken Brown 2017-09-16 22:04:19 -04:00 committed by Corinna Vinschen
parent 5952d5f08f
commit 7212b571a5
5 changed files with 13 additions and 8 deletions

View File

@ -131,7 +131,7 @@ tty_min::kill_pgrp (int sig)
for (unsigned i = 0; i < pids.npids; i++) for (unsigned i = 0; i < pids.npids; i++)
{ {
_pinfo *p = pids[i]; _pinfo *p = pids[i];
if (!p->exists () || p->ctty != ntty || p->pgid != pgid) if (!p || !p->exists () || p->ctty != ntty || p->pgid != pgid)
continue; continue;
if (p == myself) if (p == myself)
killself = sig != __SIGSETPGRP && !exit_state; killself = sig != __SIGSETPGRP && !exit_state;

View File

@ -529,7 +529,7 @@ _pinfo::set_ctty (fhandler_termios *fh, int flags)
bool __reg1 bool __reg1
_pinfo::exists () _pinfo::exists ()
{ {
return this && process_state && !(process_state & (PID_EXITED | PID_REAPED | PID_EXECED)); return process_state && !(process_state & (PID_EXITED | PID_REAPED | PID_EXECED));
} }
bool bool

View File

@ -332,7 +332,7 @@ kill_pgrp (pid_t pid, siginfo_t& si)
{ {
_pinfo *p = pids[i]; _pinfo *p = pids[i];
if (!p->exists ()) if (!p || !p->exists ())
continue; continue;
/* Is it a process we want to kill? */ /* Is it a process we want to kill? */

View File

@ -152,7 +152,8 @@ proc_can_be_signalled (_pinfo *p)
bool __reg1 bool __reg1
pid_exists (pid_t pid) pid_exists (pid_t pid)
{ {
return pinfo (pid)->exists (); pinfo p (pid);
return p && p->exists ();
} }
/* Return true if this is one of our children, false otherwise. */ /* Return true if this is one of our children, false otherwise. */
@ -1135,7 +1136,7 @@ remove_proc (int ci)
if (_my_tls._ctinfo != procs[ci].wait_thread) if (_my_tls._ctinfo != procs[ci].wait_thread)
procs[ci].wait_thread->terminate_thread (); procs[ci].wait_thread->terminate_thread ();
} }
else if (procs[ci]->exists ()) else if (procs[ci] && procs[ci]->exists ())
return true; return true;
sigproc_printf ("removing procs[%d], pid %d, nprocs %d", ci, procs[ci]->pid, sigproc_printf ("removing procs[%d], pid %d, nprocs %d", ci, procs[ci]->pid,

View File

@ -522,7 +522,7 @@ clock_gettime (clockid_t clk_id, struct timespec *tp)
pid = getpid (); pid = getpid ();
pinfo p (pid); pinfo p (pid);
if (!p->exists ()) if (!p || !p->exists ())
{ {
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
@ -746,8 +746,12 @@ clock_setres (clockid_t clk_id, struct timespec *tp)
extern "C" int extern "C" int
clock_getcpuclockid (pid_t pid, clockid_t *clk_id) clock_getcpuclockid (pid_t pid, clockid_t *clk_id)
{ {
if (pid != 0 && !pinfo (pid)->exists ()) if (pid != 0)
return (ESRCH); {
pinfo p (pid);
if (!p || !p->exists ())
return (ESRCH);
}
*clk_id = (clockid_t) PID_TO_CLOCKID (pid); *clk_id = (clockid_t) PID_TO_CLOCKID (pid);
return 0; return 0;
} }