diff mbox

[4/7] libqos: Correct mask to align size to PAGE_SIZE in malloc-pc

Message ID 1406226665-1710-5-git-send-email-marc.mari.barcelo@gmail.com
State New
Headers show

Commit Message

Marc Marí July 24, 2014, 6:31 p.m. UTC
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
---
 tests/libqos/malloc-pc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stefan Hajnoczi July 25, 2014, 3:22 p.m. UTC | #1
On Thu, Jul 24, 2014 at 08:31:02PM +0200, Marc Marí wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
>  tests/libqos/malloc-pc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
John Snow July 29, 2014, 8:47 p.m. UTC | #2
On 07/24/2014 02:31 PM, Marc Marí wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
>   tests/libqos/malloc-pc.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
> index db1496c..2efd095 100644
> --- a/tests/libqos/malloc-pc.c
> +++ b/tests/libqos/malloc-pc.c
> @@ -36,7 +36,7 @@ static uint64_t pc_alloc(QGuestAllocator *allocator, size_t size)
>   
>   
>       size += (PAGE_SIZE - 1);
> -    size &= PAGE_SIZE;
> +    size &= -PAGE_SIZE;
>   
>       g_assert_cmpint((s->start + size), <=, s->end);
>   
Reviewed-by: John Snow <jsnow@redhat.com>
Peter Maydell July 29, 2014, 9:10 p.m. UTC | #3
On 24 July 2014 19:31, Marc Marí <marc.mari.barcelo@gmail.com> wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Marc Marí <marc.mari.barcelo@gmail.com>
> ---
>  tests/libqos/malloc-pc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
> index db1496c..2efd095 100644
> --- a/tests/libqos/malloc-pc.c
> +++ b/tests/libqos/malloc-pc.c
> @@ -36,7 +36,7 @@ static uint64_t pc_alloc(QGuestAllocator *allocator, size_t size)
>
>
>      size += (PAGE_SIZE - 1);
> -    size &= PAGE_SIZE;
> +    size &= -PAGE_SIZE;

Do we have access to the osdep.h ROUND_UP macro from libqos?
If so, we could replace these two lines with
     size = ROUND_UP(size, PAGE_SIZE);

thanks
-- PMM
diff mbox

Patch

diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c
index db1496c..2efd095 100644
--- a/tests/libqos/malloc-pc.c
+++ b/tests/libqos/malloc-pc.c
@@ -36,7 +36,7 @@  static uint64_t pc_alloc(QGuestAllocator *allocator, size_t size)
 
 
     size += (PAGE_SIZE - 1);
-    size &= PAGE_SIZE;
+    size &= -PAGE_SIZE;
 
     g_assert_cmpint((s->start + size), <=, s->end);