summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormickey <mickey@openbsd.org>2003-10-15 17:42:09 +0000
committermickey <mickey@openbsd.org>2003-10-15 17:42:09 +0000
commit851ca620c0edea03e52d1bd98350ecd7bcfc9f61 (patch)
tree6561fb023603dd9e3b3d3392f9c11c037d0be690
parentDo not assert SYSRST on 1x7 boards, if we are not a SYSCON, or unexpected (diff)
downloadwireguard-openbsd-851ca620c0edea03e52d1bd98350ecd7bcfc9f61.tar.xz
wireguard-openbsd-851ca620c0edea03e52d1bd98350ecd7bcfc9f61.zip
avoid possible /0 when drawing the led load graph
-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:
*