* [PATCH] virt: acrn: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12 7:30 Deming Wang
0 siblings, 0 replies; 2+ messages in thread
From: Deming Wang @ 2023-04-12 7:30 UTC (permalink / raw)
To: andriy.shevchenko, rafael, gregkh; +Cc: linux-kernel, Deming Wang
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>
---
samples/acrn/vm-sample.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/samples/acrn/vm-sample.c b/samples/acrn/vm-sample.c
index 7abd68b20153..2656189093ef 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;
}
--
2.27.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] virt: acrn: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12 6:16 Deming Wang
0 siblings, 0 replies; 2+ messages in thread
From: Deming Wang @ 2023-04-12 6:16 UTC (permalink / raw)
To: andriy.shevchenko, rafael, gregkh; +Cc: linux-kernel, Deming Wang
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>
---
samples/acrn/vm-sample.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/samples/acrn/vm-sample.c b/samples/acrn/vm-sample.c
index 7abd68b20153..2656189093ef 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;
}
--
2.27.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-12 7:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 7:30 [PATCH] virt: acrn: Replace obsolete memalign() with posix_memalign() Deming Wang
-- strict thread matches above, loose matches on Subject: below --
2023-04-12 6:16 Deming Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®