Commit 2f975ba4 authored by Jim Brown IV's avatar Jim Brown IV Committed by Jaromir Capik

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)".
parent 00279d69
......@@ -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) = ' ';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment