struct badblock *bad, *best;
unsigned char *p = buf;
- best = 0; lo = 0; hi = badblocks.n;
+ if (badblocks.n) {
+ best = 0; lo = 0; hi = badblocks.n;
#ifdef DEBUG
- clear_progress();
- printf(";; searching badblocks for %"PRIuSEC" .. %"PRIuSEC"\n",
- pos, pos + want);
+ debug_clear_progress();
+ printf(";; searching badblocks for %"PRIuSEC" .. %"PRIuSEC"\n",
+ pos, pos + want);
#endif
- while (lo < hi) {
- mid = lo + (hi - lo)/2; bad = &badblocks.v[mid];
+ while (lo < hi) {
+ mid = lo + (hi - lo)/2; bad = &badblocks.v[mid];
#ifdef DEBUG
- printf(";; try %zu (%"PRIuSEC" .. %"PRIuSEC")... ",
- mid, bad->start, bad->end);
+ printf(";; try %zu (%"PRIuSEC" .. %"PRIuSEC")... ",
+ mid, bad->start, bad->end);
#endif
- if (pos < bad->start) { D( printf("high\n"); ) best = bad; hi = mid; }
- else if (pos >= bad->end) { D( printf("low\n"); ) lo = mid + 1; }
- else { D( printf("match!\n"); ) errno = EIO; return (-1); }
- }
+ if (pos < bad->start) { D( printf("high\n"); ) best = bad; hi = mid; }
+ else if (pos >= bad->end) { D( printf("low\n"); ) lo = mid + 1; }
+ else { D( printf("match!\n"); ) errno = EIO; return (-1); }
+ }
#ifdef DEBUG
- if (best)
- printf(";; next is %"PRIuSEC" .. %"PRIuSEC"\n",
- best->start, best->end);
+ if (best)
+ printf(";; next is %"PRIuSEC" .. %"PRIuSEC"\n",
+ best->start, best->end);
#endif
- if (best && pos + want > best->start)
- { want = best->start - pos; fakeerr = EIO; }
-
+ if (best && pos + want > best->start)
+ { want = best->start - pos; fakeerr = EIO; }
+ }
done = 0;
while (want) {
if (vob)