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)".
This commit is contained in:
Jim Brown IV 2014-06-06 17:31:02 -07:00 committed by Jaromir Capik
parent 00279d692a
commit 2f975ba49d
1 changed files with 2 additions and 4 deletions

View File

@ -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) = ' ';