cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] conga/ricci/modules/storage LV.cpp parted_wrap ...
@ 2008-01-30 17:58 rmccabe
  0 siblings, 0 replies; only message in thread
From: rmccabe @ 2008-01-30 17:58 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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

--- 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;
 }



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-30 17:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-30 17:58 [Cluster-devel] conga/ricci/modules/storage LV.cpp parted_wrap rmccabe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).