]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/utime.h: avoid comparing float with 0
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 3 Feb 2011 11:20:40 +0000 (03:20 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 3 Feb 2011 12:10:31 +0000 (04:10 -0800)
Avoid doing an exact comparison of a float with 0.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/include/utime.h

index cdd35bfca8e00870a07fc53215019e699c10bb34..1333837cfb4085af7e5b28df18fb8ffd4f4fdbda 100644 (file)
@@ -148,9 +148,10 @@ inline utime_t& operator-=(utime_t& l, double f) {
   double fs = trunc(f);
   double ns = (f - fs) * (double)1000000000.0;
   l.sec_ref() -= (long)fs;
-  if (ns) {
+  long nsl = (long)ns;
+  if (nsl) {
     l.sec_ref()--;
-    l.nsec_ref() = 1000000000L + l.nsec_ref() - (long)ns;
+    l.nsec_ref() = 1000000000L + l.nsec_ref() - nsl;
   }
   l.normalize();
   return l;