Set return value to FALSE (0) in estimate_dt in libxdrf.c
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Wed, 3 Oct 2012 15:14:33 +0000 (17:14 +0200)
committerDavid van der Spoel <spoel@xray.bmc.uu.se>
Thu, 4 Oct 2012 07:04:48 +0000 (09:04 +0200)
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

include/xdrf.h
src/gmxlib/libxdrf.c

index 5b89fa9f812c57f424302fc2ce3537009c8ac387..8b0c712df7e749835a53d0b852b47648f6b13812 100644 (file)
@@ -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);
index 4baffe77b90ed9ae7864bc52a7a95510866bc9c1..dd103a4bbb7e8bf7fcaec51295f2bf073d8a01e7 100644 (file)
@@ -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;
     }