summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-01-29 17:19:43 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-01-29 17:19:43 +0000
commite510ad03571748ea9d0b85de8d9aa9373d022322 (patch)
tree74082a3d7ca745ed293223ece819f2a8e25fe115
parent7d11b08d630592a1c0e60bbf5261fbe20291f1d9 (diff)
The Sxxx proc state defines start at 1, not 0. Also make the const
usage more correct and fix a signed/unsigned format mismatch. Based on a patch from Patrick Latifi. OK deraadt@
-rw-r--r--sys/kern/kern_proc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index ad5fb5a9661..84519c2b60e 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.17 2003/06/02 23:28:05 millert Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.18 2004/01/29 17:19:42 millert Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -386,16 +386,16 @@ orphanpg(pg)
void
proc_printit(struct proc *p, const char *modif, int (*pr)(const char *, ...))
{
- const static char *pstat[] = {
+ static const char *const pstat[] = {
"idle", "run", "sleep", "stop", "zombie", "dead"
};
char pstbuf[5];
const char *pst = pstbuf;
- if (p->p_stat > sizeof(pstat)/sizeof(*pstat))
+ if (p->p_stat < 1 || p->p_stat > sizeof(pstat) / sizeof(pstat[0]))
snprintf(pstbuf, sizeof(pstbuf), "%d", p->p_stat);
else
- pst = pstat[(int)p->p_stat];
+ pst = pstat[(int)p->p_stat - 1];
(*pr)("PROC (%s) pid=%d stat=%s flags=%b\n",
p->p_comm, p->p_pid, pst, p->p_flag, P_BITS);
@@ -405,7 +405,7 @@ proc_printit(struct proc *p, const char *modif, int (*pr)(const char *, ...))
p->p_forw, p->p_back, p->p_list.le_next, p->p_list.le_prev);
(*pr)(" user=%p, vmspace=%p\n",
p->p_addr, p->p_vmspace);
- (*pr)(" estcpu=%u, cpticks=%d, pctcpu=%d.%d%, swtime=%u\n",
+ (*pr)(" estcpu=%u, cpticks=%d, pctcpu=%u.%u%, swtime=%u\n",
p->p_estcpu, p->p_cpticks, p->p_pctcpu / 100, p->p_pctcpu % 100,
p->p_swtime);
(*pr)(" user=%llu, sys=%llu, intr=%llu\n",