All of lore.kernel.org
 help / color / mirror / Atom feed
From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/ricci/modules/storage LV.cpp parted_wrap ...
Date: 30 Jan 2008 17:58:05 -0000	[thread overview]
Message-ID: <20080130175805.5709.qmail@sourceware.org> (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

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



                 reply	other threads:[~2008-01-30 17:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080130175805.5709.qmail@sourceware.org \
    --to=rmccabe@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.