Skip to content

Commit

Permalink
virt: acrn: Replace obsolete memalign() with posix_memalign()
Browse files Browse the repository at this point in the history
memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign() and remove malloc.h include
that was there for memalign().

As a pointer is passed into posix_memalign(), initialize *p to NULL
to silence a warning about the function's return value being used as
uninitialized (which is not valid anyway because the error is properly
checked before p is returned).

Signed-off-by: Deming Wang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Deming Wang authored and gregkh committed Apr 20, 2023
1 parent b56eef3 commit 32118bd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions samples/acrn/vm-sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
Expand Down Expand Up @@ -54,8 +53,8 @@ int main(int argc, char **argv)
argc = argc;
argv = argv;

guest_memory = memalign(4096, GUEST_MEMORY_SIZE);
if (!guest_memory) {
ret = posix_memalign(&guest_memory, 4096, GUEST_MEMORY_SIZE);
if (ret < 0) {
printf("No enough memory!\n");
return -1;
}
Expand Down

0 comments on commit 32118bd

Please sign in to comment.