Skip to content

Commit

Permalink
Merge pull request #8 from a10footsquirrel/incorrect-track-bug-smalle…
Browse files Browse the repository at this point in the history
…st-absolute-value-match

Use LONG_MAX as sentinel value and use min_offset to check if errors/anomalies need to be reported
  • Loading branch information
rocky authored Mar 15, 2017
2 parents 39f208f + 55f3f34 commit d4ef140
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/paranoia/paranoia.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
#endif
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
Expand Down Expand Up @@ -1022,7 +1023,7 @@ i_iterate_stage2(cdrom_paranoia_t *p,
long j;
long min_matchbegin = -1;
long min_matchend = -1;
long min_offset = -1;
long min_offset = LONG_MAX;

/* Initialize the "sort cache" index to allow for fast searching
* through the verified fragment between (fbv,fev). (The index will
Expand Down Expand Up @@ -1060,9 +1061,8 @@ i_iterate_stage2(cdrom_paranoia_t *p,
* Note also that flags aren't used in stage 2 (since neither verified
* fragments nor the root have them).
*/
if (try_sort_sync(p, i, NULL, rc(root), j,
&matchbegin,&matchend,&offset,callback)){
if(abs(offset) < abs(min_offset) || min_offset == -1) {
if (try_sort_sync(p, i, NULL, rc(root), j, &matchbegin,&matchend,&offset,callback)){
if(labs(offset) < labs(min_offset)) {
min_matchbegin = matchbegin;
min_matchend = matchend;
min_offset = offset;
Expand All @@ -1086,11 +1086,11 @@ i_iterate_stage2(cdrom_paranoia_t *p,
* try_sort_sync() would return 2. But since root is canonical,
* we say that the fragment is off by -2.
*/
if(min_offset != -1) {
if(min_offset != LONG_MAX) {
r->begin=min_matchbegin;
r->end=min_matchend;
r->offset=-min_offset;
if(offset)if(callback)(*callback)(r->begin,PARANOIA_CB_FIXUP_EDGE);
if(min_offset)if(callback)(*callback)(r->begin,PARANOIA_CB_FIXUP_EDGE);
return(1);
}
}
Expand Down

0 comments on commit d4ef140

Please sign in to comment.