Skip to content

Commit

Permalink
Simplify pairvalidate loop
Browse files Browse the repository at this point in the history
  • Loading branch information
arr2036 committed Jun 4, 2014
1 parent 734d4fb commit 04da8cc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/lib/valuepair.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,11 @@ bool pairvalidate(VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAIR *l

check = fr_cursor_init(&filter_cursor, &filter);
match = fr_cursor_init(&list_cursor, &list);

while (true) {
if (!match && !check) goto mismatch;
while (match || check) {
/*
* Lists are of different lengths
*/
if ((!match && check) || (check && !match)) goto mismatch;

/*
* The lists are sorted, so if the first
Expand All @@ -577,12 +579,6 @@ bool pairvalidate(VALUE_PAIR const *failed[2], VALUE_PAIR *filter, VALUE_PAIR *l

check = fr_cursor_next(&filter_cursor);
match = fr_cursor_next(&list_cursor);

/*
* One list ended earlier than the others, they
* didn't match.
*/
if (!match || !check) break;
}

return true;
Expand Down

0 comments on commit 04da8cc

Please sign in to comment.