From nobody Wed Feb 11 22:55:08 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D97E3C77B6E for ; Wed, 12 Apr 2023 07:30:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjDLHay (ORCPT ); Wed, 12 Apr 2023 03:30:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbjDLHaw (ORCPT ); Wed, 12 Apr 2023 03:30:52 -0400 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 088AEF9 for ; Wed, 12 Apr 2023 00:30:50 -0700 (PDT) Received: from unicom145.biz-email.net by unicom145.biz-email.net ((D)) with ASMTP (SSL) id HBQ00048; Wed, 12 Apr 2023 15:30:48 +0800 Received: from localhost.localdomain.com (10.200.104.82) by jtjnmail201603.home.langchao.com (10.100.2.3) with Microsoft SMTP Server id 15.1.2507.21; Wed, 12 Apr 2023 15:30:47 +0800 From: Deming Wang To: , , CC: , Deming Wang Subject: [PATCH] virt: acrn: Replace obsolete memalign() with posix_memalign() Date: Wed, 12 Apr 2023 03:30:41 -0400 Message-ID: <20230412073041.2168-1-wangdeming@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.200.104.82] tUid: 20234121530489829633825b50c05662226213d82dda3 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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 #include #include -#include #include #include #include @@ -54,8 +53,8 @@ int main(int argc, char **argv) argc =3D argc; argv =3D argv; =20 - guest_memory =3D memalign(4096, GUEST_MEMORY_SIZE); - if (!guest_memory) { + ret =3D posix_memalign(&guest_memory, 4096, GUEST_MEMORY_SIZE); + if (ret < 0) { printf("No enough memory!\n"); return -1; } --=20 2.27.0