diff mbox

[4/5] exec.c: Use pow2floor() rather than hand-calculation

Message ID 1437649738-13885-5-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell July 23, 2015, 11:08 a.m. UTC
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>
---
 exec.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox

Patch

diff --git a/exec.c b/exec.c
index 7d60e15..4710e2d 100644
--- a/exec.c
+++ b/exec.c
@@ -2371,9 +2371,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;
 }