FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > 64 Studio > 64 Studio Developer

 
 
LinkBack Thread Tools
 
Old 07-10-2010, 12:28 AM
"Brian C. Lane"
 
Default Use long ints for comparisons, not floats (#608172)

floats are not suitable for comparisons, especially when comparing
against values from dialog box entries.

Related: rhbz#608172
---
storage/deviceaction.py | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/storage/deviceaction.py b/storage/deviceaction.py
index 4524e7c..3621d50 100644
--- a/storage/deviceaction.py
+++ b/storage/deviceaction.py
@@ -22,6 +22,7 @@
#

from udev import *
+import math

from devices import StorageDevice, PartitionDevice
from formats import getFormat
@@ -229,14 +230,15 @@ class ActionResizeDevice(DeviceAction):
obj = ACTION_OBJECT_DEVICE

def __init__(self, device, newsize):
- if device.currentSize == newsize:
+ currentSize = long(math.floor(device.currentSize))
+ if currentSize == newsize:
raise ValueError("new size same as old size")

if not device.resizable:
raise ValueError("device is not resizable")

DeviceAction.__init__(self, device)
- if newsize > device.currentSize:
+ if newsize > currentSize:
self.dir = RESIZE_GROW
else:
self.dir = RESIZE_SHRINK
@@ -337,11 +339,11 @@ class ActionResizeFormat(DeviceAction):
obj = ACTION_OBJECT_FORMAT

def __init__(self, device, newsize):
- if device.format.targetSize == newsize:
+ if long(math.floor(device.format.targetSize)) == newsize:
raise ValueError("new size same as old size")

DeviceAction.__init__(self, device)
- if newsize > device.format.currentSize:
+ if newsize > long(math.floor(device.format.currentSize)):
self.dir = RESIZE_GROW
else:
self.dir = RESIZE_SHRINK
--
1.7.1.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-12-2010, 06:41 PM
David Lehman
 
Default Use long ints for comparisons, not floats (#608172)

On Fri, 2010-07-09 at 17:28 -0700, Brian C. Lane wrote:
> floats are not suitable for comparisons, especially when comparing
> against values from dialog box entries.

Makes me a bit nervous, but looks okay.

Dave

>
> Related: rhbz#608172
> ---
> storage/deviceaction.py | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/storage/deviceaction.py b/storage/deviceaction.py
> index 4524e7c..3621d50 100644
> --- a/storage/deviceaction.py
> +++ b/storage/deviceaction.py
> @@ -22,6 +22,7 @@
> #
>
> from udev import *
> +import math
>
> from devices import StorageDevice, PartitionDevice
> from formats import getFormat
> @@ -229,14 +230,15 @@ class ActionResizeDevice(DeviceAction):
> obj = ACTION_OBJECT_DEVICE
>
> def __init__(self, device, newsize):
> - if device.currentSize == newsize:
> + currentSize = long(math.floor(device.currentSize))
> + if currentSize == newsize:
> raise ValueError("new size same as old size")
>
> if not device.resizable:
> raise ValueError("device is not resizable")
>
> DeviceAction.__init__(self, device)
> - if newsize > device.currentSize:
> + if newsize > currentSize:
> self.dir = RESIZE_GROW
> else:
> self.dir = RESIZE_SHRINK
> @@ -337,11 +339,11 @@ class ActionResizeFormat(DeviceAction):
> obj = ACTION_OBJECT_FORMAT
>
> def __init__(self, device, newsize):
> - if device.format.targetSize == newsize:
> + if long(math.floor(device.format.targetSize)) == newsize:
> raise ValueError("new size same as old size")
>
> DeviceAction.__init__(self, device)
> - if newsize > device.format.currentSize:
> + if newsize > long(math.floor(device.format.currentSize)):
> self.dir = RESIZE_GROW
> else:
> self.dir = RESIZE_SHRINK


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 05:07 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org