From 2f975ba49dbbb3ded655d5e400b42ae3415f52d1 Mon Sep 17 00:00:00 2001 From: Jim Brown IV Date: Fri, 6 Jun 2014 17:31:02 -0700 Subject: [PATCH] tload: fix lockup It looks like an off by one error was added to tload a couple years ago while removing goto statements. This causes tload to go into an endless loop when the load is just under a scale change integer. eg: .99, 1.99, 3.99, 7.99 to reproduce you can add, just under the loadavg at line 170 in tload.c: av[0] = 1.99; or get the load to that level separately. The patch below makes the code more like the original, but without the goto statements. This can also be fixed by just changing line 183 in tload.c from "if (0 < row)" -> "if (0 <= row)". --- tload.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tload.c b/tload.c index 680a430c..6df9ef5d 100644 --- a/tload.c +++ b/tload.c @@ -169,7 +169,7 @@ int main(int argc, char **argv) loadavg(&av[0], &av[1], &av[2]); - while (1) { + do { lines = av[0] * scale_fact; row = nrows - 1; @@ -180,9 +180,7 @@ int main(int argc, char **argv) break; } } - if (0 < row) - break; - } + } while (0 <= lines); while (row >= 0) *(screen + row-- * ncols + col) = ' ';