aboutsummaryrefslogtreecommitdiff
path: root/tests/libqos/malloc.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2016-01-11 14:10:43 -0500
committerJohn Snow <jsnow@redhat.com>2016-01-11 14:10:43 -0500
commitb1b66c3b5e89ac030e3f724791f57e9c352796ae (patch)
tree3da6973767182d7fd23534c93e76ea0951561ad3 /tests/libqos/malloc.c
parentb88641e236fbd0187858b8a974c44c2b4c450352 (diff)
libqos: allow zero-size allocations
As part of streamlining the AHCI tests interface, it'd be nice if specying a size of zero could be handled without special branches and the allocator could handle this special case gracefully. This lets me use the "ahci_io" macros for non-data commands, too, which moves me forward towards shepherding all AHCI qtests into a common set of commands in a unified pipeline. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1452282920-21550-6-git-send-email-jsnow@redhat.com
Diffstat (limited to 'tests/libqos/malloc.c')
-rw-r--r--tests/libqos/malloc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/libqos/malloc.c b/tests/libqos/malloc.c
index 82b9df537a..19d05cafa6 100644
--- a/tests/libqos/malloc.c
+++ b/tests/libqos/malloc.c
@@ -270,6 +270,10 @@ uint64_t guest_alloc(QGuestAllocator *allocator, size_t size)
uint64_t rsize = size;
uint64_t naddr;
+ if (!size) {
+ return 0;
+ }
+
rsize += (allocator->page_size - 1);
rsize &= -allocator->page_size;
g_assert_cmpint((allocator->start + rsize), <=, allocator->end);