From 7354c4df533d6cb7bcefccbcfd24e88fc7e5cf30 Mon Sep 17 00:00:00 2001 From: Doug Torrance Date: Tue, 10 Apr 2018 16:14:19 -0400 Subject: [PATCH] wmmon: Properly compute height of system load window. Previously, we looped through the history and added 100 whenever we found a larger value. This has a number of problems. In particular, * We get a maximum possible value of 5500 (100 * the number of values in the history). It is certainly possible to have a system load north of this on modern systems. * If the system load in history were to jump by more than 100 in a single step, then we wouldn't be adding enough. For example, suppose the system load in history is 175, and our height was previously computed to be 200. Suppose the next value in history is 320. We would add 100 to get a new height of 300, which isn't sufficient to display the 320. The fix is simple -- replace the if statement with a while loop, i.e., continue adding 100 until we get a height that fits our value. --- wmmon/wmmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wmmon/wmmon.c b/wmmon/wmmon.c index b3b4210..54301bd 100644 --- a/wmmon/wmmon.c +++ b/wmmon/wmmon.c @@ -910,7 +910,7 @@ void DrawStats(int *his, int num, int size, int x_left, int y_bottom) p = his; for (j=0; j pixels_per_byte) + while (p[0] > pixels_per_byte) pixels_per_byte += 100; p += 1; } -- 2.11.4.GIT