diff options
author | 2016-07-29 04:41:53 +0000 | |
---|---|---|
committer | 2016-07-29 04:41:53 +0000 | |
commit | ddc4b9731eabf3b8744985ea4539aeb62cb6c70c (patch) | |
tree | d583831704aba576b81d0ad296411416c0c68ce1 | |
parent | Store the acpi processor ID/UID in struct cpu_info, and use it to attach (diff) | |
download | wireguard-openbsd-ddc4b9731eabf3b8744985ea4539aeb62cb6c70c.tar.xz wireguard-openbsd-ddc4b9731eabf3b8744985ea4539aeb62cb6c70c.zip |
Reorder code to avoid a divide by zero when there are no sensors.
Tested by and ok mglocker@
-rw-r--r-- | sys/arch/macppc/dev/thermal.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/arch/macppc/dev/thermal.c b/sys/arch/macppc/dev/thermal.c index a7d7dbd80c0..270b79444ba 100644 --- a/sys/arch/macppc/dev/thermal.c +++ b/sys/arch/macppc/dev/thermal.c @@ -1,4 +1,4 @@ -/* $OpenBSD: thermal.c,v 1.4 2016/05/23 11:28:57 mglocker Exp $ */ +/* $OpenBSD: thermal.c,v 1.5 2016/07/29 04:41:53 jsg Exp $ */ /*- * Copyright (c) 2009-2011 Nathan Whitehorn @@ -157,17 +157,19 @@ thermal_manage_fans(void) average_excess += frac_excess; nsens++; } - average_excess /= nsens; - /* If there are no sensors in this zone, use the average */ - if (nsens_zone == 0) - max_excess_zone = average_excess; /* No sensors at all? Use default */ if (nsens == 0) { fan->fan->set(fan->fan, fan->fan->default_rpm); continue; } + average_excess /= nsens; + + /* If there are no sensors in this zone, use the average */ + if (nsens_zone == 0) + max_excess_zone = average_excess; + /* * Scale the fan linearly in the max temperature in its * thermal zone. |