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 B762CC77B6E for ; Wed, 12 Apr 2023 07:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229588AbjDLH1A (ORCPT ); Wed, 12 Apr 2023 03:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjDLH05 (ORCPT ); Wed, 12 Apr 2023 03:26:57 -0400 X-Greylist: delayed 64 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 12 Apr 2023 00:26:54 PDT Received: from ssh248.corpemail.net (ssh248.corpemail.net [210.51.61.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 144A8FA for ; Wed, 12 Apr 2023 00:26:53 -0700 (PDT) Received: from ssh248.corpemail.net by ssh248.corpemail.net ((D)) with ASMTP (SSL) id HBL00142; Wed, 12 Apr 2023 15:25:42 +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:25:42 +0800 From: Deming Wang To: , CC: , , Deming Wang Subject: [PATCH] tools/virtio/ringtest: Replace obsolete memalign() with posix_memalign() Date: Wed, 12 Apr 2023 03:25:36 -0400 Message-ID: <20230412072536.2029-1-wangdeming@inspur.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.200.104.82] tUid: 20234121525426b2ff674ebb2c8b70bbc1e239a9a10c3 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 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/virtio/ringtest/ptr_ring.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c index c9b26335f891..a0bf4978eace 100644 --- a/tools/virtio/ringtest/ptr_ring.c +++ b/tools/virtio/ringtest/ptr_ring.c @@ -26,9 +26,12 @@ typedef int gfp_t; static void *kmalloc(unsigned size, gfp_t gfp) { - void *p = memalign(64, size); - if (!p) - return p; + void *p; + int ret; + + ret = posix_memalign(&p, 64, size); + if (ret < 0) + return NULL; if (gfp & __GFP_ZERO) memset(p, 0, size); -- 2.27.0