summaryrefslogtreecommitdiffstats
path: root/samples/acrn/vm-sample.c
diff options
context:
space:
mode:
authorDeming Wang <wangdeming@inspur.com>2023-04-12 03:30:41 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-04-20 14:20:51 +0200
commit32118bdc9471f6d28dbf3d55b2bf0f912be0c62b (patch)
tree6cae0432d893064dec84152f6a390e602e137e88 /samples/acrn/vm-sample.c
parentb56eef3e16d888883fefab47425036de80dd38fc (diff)
downloadlinux-stable-32118bdc9471f6d28dbf3d55b2bf0f912be0c62b.tar.gz
linux-stable-32118bdc9471f6d28dbf3d55b2bf0f912be0c62b.tar.bz2
linux-stable-32118bdc9471f6d28dbf3d55b2bf0f912be0c62b.zip
virt: acrn: Replace obsolete memalign() with posix_memalign()
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 <wangdeming@inspur.com> Link: https://lore.kernel.org/r/20230412073041.2168-1-wangdeming@inspur.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'samples/acrn/vm-sample.c')
-rw-r--r--samples/acrn/vm-sample.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/samples/acrn/vm-sample.c b/samples/acrn/vm-sample.c
index 7abd68b20153..704402c64ea3 100644
--- a/samples/acrn/vm-sample.c
+++ b/samples/acrn/vm-sample.c
@@ -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>
@@ -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;
}