Skip to contentSkip to conversation

conga/ricci/modules/storage LV.cpp parted_wrap ...

Cluster-devel [email protected] 1 participant 1 message Jan 30, 2008

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2008-01-30 17:58:05

Modified files:
ricci/modules/storage: LV.cpp parted_wrapper.cpp

Log message:
don't use floating point arithmetic where not necessary (i.e., anywhere for RHEL5)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/LV.cpp.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/storage/parted_wrapper.cpp.diff?cvsroot=cluster&r1=1.12&r2=1.13

ricci/modules/storage/LV.cpp +1 -1
@@ -124,7 +124,7 @@
     long long min  = utils::to_long(xml.get_attr("min"));
     long long max  = utils::to_long(xml.get_attr("max"));
     long long step = utils::to_long(xml.get_attr("step"));
-    long long min_size = (long long ) (size * (usage / 100.0));
+    long long min_size = (long long) (size * usage) / 100;
     if (min_size > min)
       min = min_size;
     else if (min_size > max)
ricci/modules/storage/parted_wrapper.cpp +5 -4
@@ -667,11 +667,13 @@
   String s = utils::to_lower(utils::strip(size_str));
   long long multiplier;
   // parted defines 1KB as 1000 bytes.
-  if (s.find("b") == s.npos)
+  if (s.find("b") == s.npos) {
     multiplier = 1000 * 1000;  // by old parted behavior, size is in MB
-  else {
+    return (long long) utils::to_long(s) * multiplier;
+  } else {
     if (s.size() < 3)
       throw String("parted size has an invalid value: ") + s;
+	/* This path should never be hit on RHEL5 and later. */
     multiplier = 1;
     if (s[s.size()-2] == 'k')
       multiplier = 1000;
@@ -681,7 +683,6 @@
       multiplier = 1000 * 1000 * 1000;
     else if (s[s.size()-2] == 't')
       multiplier = (long long) 1000 * 1000 * 1000 * 1000;
+    return (long long) utils::to_float(s) * multiplier;
   }
-
-  return (long long) utils::to_float(s) * multiplier;
 }