dvd-sector-copy.c: Fix final recovery.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 18 Feb 2022 22:57:13 +0000 (22:57 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 18 Feb 2022 22:57:13 +0000 (22:57 +0000)
Write this the other way around, because it's easier to read that way.
And then notice that it's broken because it doesn't actually set the
return value properly.

dvd-sector-copy.c

index dd97d8b..98ee8ec 100644 (file)
@@ -710,10 +710,12 @@ static ssize_t find_good_sector(secaddr *pos_inout, secaddr end,
     else bad_hi = pos + n + 1;
   }
   recovered(bad_lo, bad_hi); *pos_inout = good;
-  if (r.pos + r.start <= good && good <= r.pos + r.end) {
-    rearrange_sectors(&r, 0, good - r.pos, r.pos + r.end - good);
-  } else
+  if (good < r.pos + r.start || r.pos + r.end <= good)
     n = 0;
+  else {
+    n = r.pos + r.end - good;
+    rearrange_sectors(&r, 0, good - r.pos, n);
+  }
   return (n);
 }