Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp565922rwl; Wed, 12 Apr 2023 00:26:56 -0700 (PDT) X-Google-Smtp-Source: AKy350Z5/kME/qFvZCSpGxiFACFP29Gz6qhROoKDfv1DP7j2tk8aOhPm0BCDfgQjWu8Kpu41ldTH X-Received: by 2002:a05:6402:12cd:b0:504:a360:e611 with SMTP id k13-20020a05640212cd00b00504a360e611mr8701340edx.13.1681284415890; Wed, 12 Apr 2023 00:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681284415; cv=none; d=google.com; s=arc-20160816; b=bahUL0hmurw/QjdUBrhxuJ5XqymtvgzpzOPn66tT/Ojy64lHqa41aPDJ4mZhaLxqR/ qG/RMicBC7VgJbw8EKbnPEJAhsQDNHBS+n7I94WNVOuxkgOkmRnyRlVAo4sL7byrOrCU 1qZdk127wGD3+FwCa85592T0hVaY18yQIz4z3ZlEYIkWQZ6qobMXmwwmgka5PYxsNp9Y difOeKSBqEyTjgjujt3cxPRpgE07jvKmR+TqfGL6G2V1z4Otx0h3RHneSKSqWDv9uGf8 TwRcnotzi8+GySST6s0NpGzNBxQc1b34EKXCp8/jbF+rIiUSErx07cKJo1EEZ/X8FaeZ kj1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=yv+eKIVuQ7LZMryQOhnN8rdI5Ju+EKVoIcmKWJ8ptcM=; b=VIPM9HNGQQM+RCXohZt8nM0SZZIQBhtqfbt9kM5X5L6MqxfVqCOgF45LTnAjTjRQan Ps7nlpy1wcOOKoeGJlPOMzVR94W7s/65/Jmt2TQl8nobwlMtDAmMTlJGCX4vBhyDCtZ3 CVTZp1VR2M+WQezP0j8FZx+X5urmuc3bdbhbqen8SWTGdJKwTG9xOqpuN0LN3thy9xJ6 y//omrdK85Lkm8NeZ659C6O6+qa+uZFRjZjAeEr/orxs5Y2WSPQbk7AX6IBhbvtqJv6A /8neOdo279ZqygecNSjgl8HKEsnKRisQ8hRHIMIEsSmf8H4ZoDf0xT6BQMrZF9Hf7Mi5 6tpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a056402032f00b004fc9c7986c5si14549750edw.530.2023.04.12.00.26.30; Wed, 12 Apr 2023 00:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229513AbjDLHSI (ORCPT + 99 others); Wed, 12 Apr 2023 03:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDLHSH (ORCPT ); Wed, 12 Apr 2023 03:18:07 -0400 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 014081713 for ; Wed, 12 Apr 2023 00:18:00 -0700 (PDT) Received: from unicom145.biz-email.net by unicom145.biz-email.net ((D)) with ASMTP (SSL) id HBD00056; Wed, 12 Apr 2023 15:17:56 +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:17:55 +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:17:53 -0400 Message-ID: <20230412071753.1966-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: 202341215175682d1f7c533356d546f6d3bdac4f0bacd 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 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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