From 7331057321b807552cdbebb06cb6ba972c394b9c Mon Sep 17 00:00:00 2001 From: fgvieira <1151762+fgvieira@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:24:23 +0200 Subject: [PATCH] Improve error message on EOF --- shared/read_data.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/shared/read_data.cpp b/shared/read_data.cpp index 29ab127..b479fb3 100644 --- a/shared/read_data.cpp +++ b/shared/read_data.cpp @@ -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 @@ -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