Skip to content

Commit 7331057

Browse files
committed
Improve error message on EOF
1 parent 01091a0 commit 7331057

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

shared/read_data.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@ double*** read_geno(char *in_geno, bool in_bin, bool in_probs, bool *in_logscale
2828
for(uint64_t s = 0; s < n_sites; s++){
2929
if(in_bin){
3030
for(uint64_t i = 0; i < n_ind; i++){
31-
if( gzread(in_geno_fh, geno[i][s], N_GENO * sizeof(double)) != N_GENO * sizeof(double) )
32-
error(__FUNCTION__, "cannot read binary GENO file. Check GENO file and number of sites!");
31+
if( gzread(in_geno_fh, geno[i][s], N_GENO * sizeof(double)) != N_GENO * sizeof(double) ){
32+
if (gzeof(in_geno_fh))
33+
error(__FUNCTION__, "GENO file at premature EOF. Check GENO file and number of sites!");
34+
else
35+
error(__FUNCTION__, "cannot read binary GENO file. Check GENO file and number of sites!");
36+
}
3337
if(!*in_logscale)
3438
conv_space(geno[i][s], N_GENO, log);
3539
// Normalize GL
@@ -42,7 +46,7 @@ double*** read_geno(char *in_geno, bool in_bin, bool in_probs, bool *in_logscale
4246
}
4347
}
4448
else{
45-
if( gzgets(in_geno_fh, buf, BUFF_LEN) == NULL) {
49+
if( gzgets(in_geno_fh, buf, BUFF_LEN) == NULL){
4650
if (gzeof(in_geno_fh))
4751
error(__FUNCTION__, "GENO file at premature EOF. Check GENO file and number of sites!");
4852
else

0 commit comments

Comments
 (0)