From patchwork Wed Apr 12 06:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deming Wang X-Patchwork-Id: 13208583 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 9867EC7619A for ; Wed, 12 Apr 2023 06:59:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbjDLG7S (ORCPT ); Wed, 12 Apr 2023 02:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbjDLG7R (ORCPT ); Wed, 12 Apr 2023 02:59:17 -0400 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 11 Apr 2023 23:59:15 PDT Received: from unicom146.biz-email.net (unicom146.biz-email.net [210.51.26.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9BE61989; Tue, 11 Apr 2023 23:59:15 -0700 (PDT) Received: from unicom146.biz-email.net by unicom146.biz-email.net ((D)) with ASMTP (SSL) id HAS00006; Wed, 12 Apr 2023 14:58:06 +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 14:58:05 +0800 From: Deming Wang To: , CC: , , , Deming Wang Subject: [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign() Date: Wed, 12 Apr 2023 02:58:04 -0400 Message-ID: <20230412065804.1831-1-wangdeming@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Originating-IP: [10.200.104.82] tUid: 20234121458061f18159807e484f5929ba5640fe62a67 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/soft-dirty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c index 21d8830c5f24..4bb7421141a2 100644 --- a/tools/testing/selftests/mm/soft-dirty.c +++ b/tools/testing/selftests/mm/soft-dirty.c @@ -80,8 +80,8 @@ static void test_hugepage(int pagemap_fd, int pagesize) int i, ret; size_t hpage_len = read_pmd_pagesize(); - map = memalign(hpage_len, hpage_len); - if (!map) + ret = posix_memalign((void *)(&map), hpage_len, hpage_len) + if (ret < 0) ksft_exit_fail_msg("memalign failed\n"); ret = madvise(map, hpage_len, MADV_HUGEPAGE);