From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIcS5-0001J6-Nh for qemu-devel@nongnu.org; Fri, 24 Jul 2015 08:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIcS4-000084-Pn for qemu-devel@nongnu.org; Fri, 24 Jul 2015 08:51:49 -0400 From: Peter Maydell Date: Fri, 24 Jul 2015 13:33:10 +0100 Message-Id: <1437741192-20955-5-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> References: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH v2 4/6] exec.c: Use pow2floor() rather than hand-calculation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, "Michael S. Tsirkin" , patches@linaro.org, Keith Busch , Paolo Bonzini Use pow2floor() to round down to the nearest power of 2, rather than an inline calculation. Signed-off-by: Peter Maydell --- exec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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; } -- 1.9.1