Avoid division by zero when calculating CPU usage.
from upstream git
This commit is contained in:
parent
d414bb5e45
commit
51509777e8
@ -1,10 +1,11 @@
|
||||
# $OpenBSD: Makefile,v 1.4 2012/05/14 07:54:23 jasper Exp $
|
||||
# $OpenBSD: Makefile,v 1.5 2012/07/07 09:43:54 jasper Exp $
|
||||
|
||||
ONLY_FOR_ARCHS= ${APM_ARCHS}
|
||||
|
||||
COMMENT= generate a statusbar for use with i3/xmobar/dzen2
|
||||
|
||||
DISTNAME= i3status-2.5.1
|
||||
REVISION= 0
|
||||
CATEGORIES= x11 sysutils
|
||||
|
||||
HOMEPAGE= http://i3wm.org/i3status/
|
||||
|
25
x11/i3status/patches/patch-src_print_cpu_usage_c
Normal file
25
x11/i3status/patches/patch-src_print_cpu_usage_c
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-src_print_cpu_usage_c,v 1.3 2012/07/07 09:43:54 jasper Exp $
|
||||
|
||||
Avoid division by zero when calculating CPU usage.
|
||||
Upstream git 859a7690a6472ca6d700d29693d986125d11e4b6
|
||||
|
||||
--- src/print_cpu_usage.c.orig Fri May 11 22:38:26 2012
|
||||
+++ src/print_cpu_usage.c Sat Jul 7 11:41:55 2012
|
||||
@@ -40,7 +40,7 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer,
|
||||
curr_total = curr_user + curr_nice + curr_system + curr_idle;
|
||||
diff_idle = curr_idle - prev_idle;
|
||||
diff_total = curr_total - prev_total;
|
||||
- diff_usage = (1000 * (diff_total - diff_idle)/diff_total + 5)/10;
|
||||
+ diff_usage = (diff_total ? (1000 * (diff_total - diff_idle)/diff_total + 5)/10 : 0);
|
||||
prev_total = curr_total;
|
||||
prev_idle = curr_idle;
|
||||
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
@@ -71,7 +71,7 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer,
|
||||
curr_total = curr_user + curr_nice + curr_system + curr_idle;
|
||||
diff_idle = curr_idle - prev_idle;
|
||||
diff_total = curr_total - prev_total;
|
||||
- diff_usage = (1000 * (diff_total - diff_idle)/diff_total + 5)/10;
|
||||
+ diff_usage = (diff_total ? (1000 * (diff_total - diff_idle)/diff_total + 5)/10 : 0);
|
||||
prev_total = curr_total;
|
||||
prev_idle = curr_idle;
|
||||
#else
|
Loading…
Reference in New Issue
Block a user