[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/ricci/modules/storage LV.cpp parted_wrap ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe 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

--- conga/ricci/modules/storage/LV.cpp	2007/09/11 02:45:28	1.10
+++ conga/ricci/modules/storage/LV.cpp	2008/01/30 17:58:05	1.11
@@ -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)
--- conga/ricci/modules/storage/parted_wrapper.cpp	2007/09/11 02:45:28	1.12
+++ conga/ricci/modules/storage/parted_wrapper.cpp	2008/01/30 17:58:05	1.13
@@ -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;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]