From: David van der Spoel Date: Wed, 3 Oct 2012 15:14:33 +0000 (+0200) Subject: Set return value to FALSE (0) in estimate_dt in libxdrf.c X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=c5d23c84623fe9106a5da65e768c687ddfa33798;p=alexxy%2Fgromacs.git Set return value to FALSE (0) in estimate_dt in libxdrf.c To be on the safe side the function to estimate the time step betwen frames was fixed such that the return value bOK is always set even if the file was missing or empty. In addition the function is made static since it is not used outside the file. Change-Id: I8706a23b7a198f9d0718f1bfcb4a7770b2e6e53c --- diff --git a/include/xdrf.h b/include/xdrf.h index 5b89fa9f81..8b0c712df7 100644 --- a/include/xdrf.h +++ b/include/xdrf.h @@ -100,9 +100,7 @@ int xdr_gmx_large_int(XDR *xdrs,gmx_large_int_t *i,const char *warn); * "WARNING during %s:", where warn is printed in %s. */ -float xdr_xtc_estimate_dt(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK); - - int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekForwardOnly); +int xdr_xtc_seek_time(real time, FILE *fp, XDR *xdrs, int natoms,gmx_bool bSeekForwardOnly); int xdr_xtc_seek_frame(int frame, FILE *fp, XDR *xdrs, int natoms); diff --git a/src/gmxlib/libxdrf.c b/src/gmxlib/libxdrf.c index 4baffe77b9..dd103a4bbb 100644 --- a/src/gmxlib/libxdrf.c +++ b/src/gmxlib/libxdrf.c @@ -1567,7 +1567,7 @@ static gmx_off_t xtc_get_next_frame_start(FILE *fp, XDR *xdrs, int natoms) } - +static float xdr_xtc_estimate_dt(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) { @@ -1575,14 +1575,13 @@ xdr_xtc_estimate_dt(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) float tinit; gmx_off_t off; + *bOK = 0; if((off = gmx_ftell(fp)) < 0){ return -1; } tinit = xtc_get_current_frame_time(fp,xdrs,natoms,bOK); - *bOK = 1; - if(!(*bOK)) { return -1; @@ -1596,7 +1595,7 @@ xdr_xtc_estimate_dt(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK) } res -= tinit; - if(gmx_fseek(fp,off,SEEK_SET)){ + if (0 != gmx_fseek(fp,off,SEEK_SET)) { *bOK = 0; return -1; }