From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQObc-0005JI-8L for qemu-devel@nongnu.org; Fri, 14 Aug 2015 19:41:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQObb-0006Pb-EX for qemu-devel@nongnu.org; Fri, 14 Aug 2015 19:41:48 -0400 Sender: Paolo Bonzini References: <1437741192-20955-1-git-send-email-peter.maydell@linaro.org> <1437741192-20955-5-git-send-email-peter.maydell@linaro.org> From: Paolo Bonzini Message-ID: <55CE7CB3.3000604@redhat.com> Date: Sat, 15 Aug 2015 01:41:39 +0200 MIME-Version: 1.0 In-Reply-To: <1437741192-20955-5-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [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: Peter Maydell , qemu-devel@nongnu.org Cc: Kevin Wolf , Keith Busch , patches@linaro.org, qemu-block@nongnu.org, "Michael S. Tsirkin" On 24/07/2015 14:33, Peter Maydell wrote: > 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); Reviewed-by: Paolo Bonzini > return l; > } >