summaryrefslogtreecommitdiff
path: root/sys/arch/hppa
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-10-15 17:42:10 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-10-15 17:42:10 +0000
commit4118f0944cf6b9e0f8714361622404ffe4a6d9a2 (patch)
tree736ea2c63bb3a22d6367e93a675a666c94184eba /sys/arch/hppa
parent753f50ac71218c3f5acd254b377fffa1e6f08155 (diff)
avoid possible /0 when drawing the led load graph
Diffstat (limited to 'sys/arch/hppa')
-rw-r--r--sys/arch/hppa/hppa/autoconf.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/arch/hppa/hppa/autoconf.c b/sys/arch/hppa/hppa/autoconf.c
index 18bf364979b..769af32f061 100644
--- a/sys/arch/hppa/hppa/autoconf.c
+++ b/sys/arch/hppa/hppa/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.35 2003/07/30 22:29:45 mickey Exp $ */
+/* $OpenBSD: autoconf.c,v 1.36 2003/10/15 17:42:09 mickey Exp $ */
/*
* Copyright (c) 1998-2003 Michael Shalayeff
@@ -132,19 +132,21 @@ heartbeat(v)
void *v;
{
static u_int hbcnt = 0, ocp_total, ocp_idle;
- int toggle, cp_mask, cp_total;
+ int toggle, cp_mask, cp_total, cp_idle;
timeout_add(&heartbeat_tmo, hz / 16);
+ cp_idle = cp_time[CP_IDLE];
cp_total = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS] +
cp_time[CP_INTR] + cp_time[CP_IDLE];
- if (!cp_total)
- cp_total = 1;
- cp_mask = 0xf0 >> (cp_time[CP_IDLE] - ocp_idle) * 4 /
- (cp_total - ocp_total);
+ if (cp_total == ocp_total)
+ cp_total = ocp_total + 1;
+ if (cp_idle == ocp_idle)
+ cp_idle = ocp_idle + 1;
+ cp_mask = 0xf0 >> (cp_idle - ocp_idle) * 4 / (cp_total - ocp_total);
cp_mask &= 0xf0;
ocp_total = cp_total;
- ocp_idle = cp_time[CP_IDLE];
+ ocp_idle = cp_idle;
/*
* do this:
*