]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
exec.c: Use pow2floor() rather than hand-calculation
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 24 Jul 2015 12:33:10 +0000 (13:33 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 7 Sep 2015 13:19:00 +0000 (14:19 +0100)
Use pow2floor() to round down to the nearest power of 2,
rather than an inline calculation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1437741192-20955-5-git-send-email-peter.maydell@linaro.org

exec.c

diff --git a/exec.c b/exec.c
index 54cd70ac1e0bc47af889b6c93224b9e783fd637e..31d2dc79bce58c27ea232da0d60fe7f5b2a30d3b 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -2374,9 +2374,7 @@ static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr)
     if (l > access_size_max) {
         l = access_size_max;
     }
-    if (l & (l - 1)) {
-        l = 1 << (qemu_fls(l) - 1);
-    }
+    l = pow2floor(l);
 
     return l;
 }