aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-07-06 13:19:21 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-07-10 21:46:57 -0400
commitae8d57e650543103c5545d1a2fe18e667cc5c001 (patch)
tree83cfd2f983f8d97543a0a9efe2aba9324513d3aa
parentb0b2e9c4aaa793cf38aa26646f2130cca2f49d83 (diff)
downloadkutter-ae8d57e650543103c5545d1a2fe18e667cc5c001.tar.gz
kutter-ae8d57e650543103c5545d1a2fe18e667cc5c001.tar.xz
kutter-ae8d57e650543103c5545d1a2fe18e667cc5c001.zip
stepcompress: Fix compress_bisect_add() infinite loop
At high step speeds, it is possible to exit the inner scan due to integer truncation. Always update minadd or maxadd so that the outer loop always terminates. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/stepcompress.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c
index d39bbc32..569522a6 100644
--- a/klippy/stepcompress.c
+++ b/klippy/stepcompress.c
@@ -174,11 +174,15 @@ compress_bisect_add(struct stepcompress *sc)
// Check if a greater or lesser add could extend the sequence
int32_t maxreach = add*addfactor + maxinterval*(count+1);
- if (maxreach < point.minp)
+ if (maxreach < point.minp) {
+ minadd = add;
origmaxinterval = maxinterval;
- else
+ } else {
+ maxadd = add;
origmininterval = mininterval;
+ }
+ // See if next point would further limit the add range
if ((minadd+1)*addfactor + origmaxinterval*(count+1) < point.minp)
minadd = idiv_up(point.minp - origmaxinterval*(count+1)
, addfactor) - 1;