Skip to content

Commit

Permalink
lib/ukalloc: uk_posix_memalign_ifpages: Return zero on success
Browse files Browse the repository at this point in the history
According to the Linux Programmer's Manual,
posix_memalign() returns zero on success instead
of a pointer value.

Signed-off-by: Kenichi Yasukata <kenichi.yasukata@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
  • Loading branch information
yasukata authored and skuenzer committed May 3, 2018
1 parent 0dba10c commit a323fbd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/ukalloc/alloc.c
Expand Up @@ -225,7 +225,7 @@ int uk_posix_memalign_ifpages(struct uk_alloc *a,

if (!size) {
*memptr = NULL;
return 0;
return EINVAL;
}

/* For page-aligned memory blocks, the size information is not stored
Expand All @@ -244,7 +244,8 @@ int uk_posix_memalign_ifpages(struct uk_alloc *a,
return ENOMEM;

*intptr = order;
return ALIGN_UP((uintptr_t)intptr + sizeof(order), align);
*memptr = (void *) ALIGN_UP((uintptr_t)intptr + sizeof(order), align);
return 0;
}

#endif
Expand All @@ -268,7 +269,7 @@ void *uk_memalign_compat(struct uk_alloc *a, size_t align, size_t size)
void *ptr;

UK_ASSERT(a);
if (!uk_posix_memalign(a, &ptr, align, size))
if (uk_posix_memalign(a, &ptr, align, size) != 0)
return NULL;

return ptr;
Expand Down

0 comments on commit a323fbd

Please sign in to comment.