- while (!feof(f_idx) && !b_Found){
- if (fread(®,sizeof(EMUFS_IDX),1,f_idx) != 1) continue;
- if (reg.n_idreg == n_IdReg) b_Found = 1;
+ while (!feof(f_idx)) {
+ if (fread(®, sizeof(EMUFS_IDX), 1, f_idx) != 1) {
+ if (feof(f_idx)) break; /* No leyó por EOF */
+ PERR("Error al leer registros de idx");
+ /* *err = 3; * EMUFS_ERROR_FILE_READ */
+ return EMUFS_NOT_FOUND;
+ }
+ if (reg.n_idreg == reg_id) {
+ fclose(f_idx);
+ return reg.n_location;
+ }