| 785 | } |
| 786 | |
| 787 | struct file_list *flist_for_ndx(int ndx, const char *fatal_error_loc) |
| 788 | { |
| 789 | struct file_list *flist = cur_flist; |
| 790 | |
| 791 | if (!flist && !(flist = first_flist)) |
| 792 | goto not_found; |
| 793 | |
| 794 | while (ndx < flist->ndx_start-1) { |
| 795 | if (flist == first_flist) |
| 796 | goto not_found; |
| 797 | flist = flist->prev; |
| 798 | } |
| 799 | while (ndx >= flist->ndx_start + flist->used) { |
| 800 | if (!(flist = flist->next)) |
| 801 | goto not_found; |
| 802 | } |
| 803 | return flist; |
| 804 | |
| 805 | not_found: |
| 806 | if (fatal_error_loc) { |
| 807 | int first, last; |
| 808 | if (first_flist) { |
| 809 | first = first_flist->ndx_start - 1; |
| 810 | last = first_flist->prev->ndx_start + first_flist->prev->used - 1; |
| 811 | } else { |
| 812 | first = 0; |
| 813 | last = -1; |
| 814 | } |
| 815 | rprintf(FERROR, |
| 816 | "File-list index %d not in %d - %d (%s) [%s]\n", |
| 817 | ndx, first, last, fatal_error_loc, who_am_i()); |
| 818 | exit_cleanup(RERR_PROTOCOL); |
| 819 | } |
| 820 | return NULL; |
| 821 | } |
| 822 | |
| 823 | const char *who_am_i(void) |
| 824 | { |
no test coverage detected