Skip to content

Commit

Permalink
Improve error message on EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
fgvieira committed Aug 11, 2023
1 parent 01091a0 commit 7331057
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions shared/read_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ double*** read_geno(char *in_geno, bool in_bin, bool in_probs, bool *in_logscale
for(uint64_t s = 0; s < n_sites; s++){
if(in_bin){
for(uint64_t i = 0; i < n_ind; i++){
if( gzread(in_geno_fh, geno[i][s], N_GENO * sizeof(double)) != N_GENO * sizeof(double) )
error(__FUNCTION__, "cannot read binary GENO file. Check GENO file and number of sites!");
if( gzread(in_geno_fh, geno[i][s], N_GENO * sizeof(double)) != N_GENO * sizeof(double) ){
if (gzeof(in_geno_fh))
error(__FUNCTION__, "GENO file at premature EOF. Check GENO file and number of sites!");
else
error(__FUNCTION__, "cannot read binary GENO file. Check GENO file and number of sites!");
}
if(!*in_logscale)
conv_space(geno[i][s], N_GENO, log);
// Normalize GL
Expand All @@ -42,7 +46,7 @@ double*** read_geno(char *in_geno, bool in_bin, bool in_probs, bool *in_logscale
}
}
else{
if( gzgets(in_geno_fh, buf, BUFF_LEN) == NULL) {
if( gzgets(in_geno_fh, buf, BUFF_LEN) == NULL){
if (gzeof(in_geno_fh))
error(__FUNCTION__, "GENO file at premature EOF. Check GENO file and number of sites!");
else
Expand Down

0 comments on commit 7331057

Please sign in to comment.