From patchwork Wed Apr 12 07:49:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deming Wang X-Patchwork-Id: 13208594 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 DAE4DC7619A for ; Wed, 12 Apr 2023 07:49:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbjDLHte (ORCPT ); Wed, 12 Apr 2023 03:49:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229887AbjDLHtd (ORCPT ); Wed, 12 Apr 2023 03:49:33 -0400 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 184493A98; Wed, 12 Apr 2023 00:49:29 -0700 (PDT) Received: from unicom145.biz-email.net by unicom145.biz-email.net ((D)) with ASMTP (SSL) id HBJ00027; Wed, 12 Apr 2023 15:49:27 +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:49:26 +0800 From: Deming Wang To: , CC: , , , Deming Wang Subject: [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign() Date: Wed, 12 Apr 2023 03:49:15 -0400 Message-ID: <20230412074915.2303-1-wangdeming@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.200.104.82] tUid: 2023412154927bed2c8f64373bf4344b6b1b5d5e3769a 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-kselftest@vger.kernel.org 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 --- tools/testing/selftests/mm/split_huge_page_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index cbb5e6893cbf..8f48f07bc821 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -96,10 +96,10 @@ void split_pmd_thp(void) char *one_page; size_t len = 4 * pmd_pagesize; size_t i; + int ret; - one_page = memalign(pmd_pagesize, len); - - if (!one_page) { + ret = posix_memalign((void **)(&one_page), pmd_pagesize, len); + if (ret < 0) { printf("Fail to allocate memory\n"); exit(EXIT_FAILURE); }