downloadingfilenum++;
}
}
- if (downloadingfilenum == antfsdir_used) {
+ if (downloadingfilenum >= antfsdir_used) {
printf("No files to download");
} else {
D("downloading first file (%d)\n", antfsdir[downloadingfilenum].fileno);
downloadfinished = 1;
} else {
downloadingfilenum++;
- while (! interesting_file(&antfsdir[downloadingfilenum], antfsdir_used)) {
+ while (downloadingfilenum < antfsdir_used &&
+ ! interesting_file(&antfsdir[downloadingfilenum], antfsdir_used)) {
D("Skipping %d; not .fit file\n", downloadingfilenum);
downloadingfilenum++;
}