[master 1/1] use floor division in calculating amount to reclaim (#1245446)

AdamWill installerbot-noreply at redhat.com
Thu Jul 23 06:52:12 UTC 2015


From: Adam Williamson <awilliam at redhat.com>

Using true division results in a float, which eventually causes
a crash when the value is passed to sectorsToSize(), which
tries to multiply it by a Size. Multiplying a float by a Size
doesn't work. sectorsToSize() does specify that it needs an int.
This is a python2 vs. python3 thing: in py2, int/int returns
an int. See PEP 238.
This fixes #1245854 and #1245446 (tested).
---
 blivet/partitioning.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index 0e85eac..69e79e5 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -1587,7 +1587,7 @@ def manageSizeSets(size_sets, chunks):
                     if ss.needed < 0:
                         # it would be good to take back some from each device
                         # instead of taking all from the last one(s)
-                        extra = -chunk.sizeToLength(needed) / len(ss.devices)
+                        extra = -chunk.sizeToLength(needed) // len(ss.devices)
                         if extra > request.growth and i == 0:
                             log.debug("not reclaiming from this request")
                             continue


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/075ebeb22276c10d868decda2cd8bfb57c433f0b


More information about the anaconda-patches mailing list