shithub: riscv

Download patch

ref: f42f1f2dbdc59b8b065e9740ca51eddd2f5ae698
parent: e02e1188e472c7e2f40fa84e839631cc54f505a0
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Sep 15 09:23:42 EDT 2022

aux/acpi: fix division by zero (thanks umbraticus)

--- a/sys/src/cmd/aux/acpi.c
+++ b/sys/src/cmd/aux/acpi.c
@@ -210,7 +210,7 @@
 				ss = st.capacity * 3600 / st.rate;
 			if(bats[n].fullcharge > 0){
 				x = st.capacity * 100 / bats[n].fullcharge;
-				if(st.state & 2)
+				if(st.rate > 0 && (st.state & 2) != 0)
 					ss = (bats[n].fullcharge - st.capacity) * 3600 / st.rate;
 			}
 		}else{