From patchwork Thu Apr 18 10:33:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Ananyev X-Patchwork-Id: 139491 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3767543E9F; Thu, 18 Apr 2024 12:33:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BFC8F40A72; Thu, 18 Apr 2024 12:33:47 +0200 (CEST) Received: from forward500a.mail.yandex.net (forward500a.mail.yandex.net [178.154.239.80]) by mails.dpdk.org (Postfix) with ESMTP id D0F1940A4B for ; Thu, 18 Apr 2024 12:33:45 +0200 (CEST) Received: from mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7907:0:640:8f19:0]) by forward500a.mail.yandex.net (Yandex) with ESMTPS id 9FA766163F; Thu, 18 Apr 2024 13:33:45 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id GXCBSvCo7Ko0-tjxQX3j8; Thu, 18 Apr 2024 13:33:44 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1713436424; bh=iYvpuGQKjhKfmIR1ELDCiEoTXNl5G8cJLjeY0lPHCo4=; h=Cc:Message-Id:References:Date:In-Reply-To:Subject:To:From; b=VSiREZw43ARFs4eNxHl23xcrOQYl6LPg9I5XrdJl8kv13ZgTq5IMvgiq9ElluWwQ+ pdhA7ozHBFRQw8nekbv/Y7RR31WIxKxWNW16cZ8Kb0CXztni3CQYOwn3SIomIMUpPf 53EJenckbc7Ah/w3BlIUDmXEY8aSfEeQiQIbYq0Q= Authentication-Results: mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Konstantin Ananyev To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@amd.com, andrew.rybchenko@oktetlabs.ru, yipeng1.wang@intel.com, sameh.gobriel@intel.com, bruce.richardson@intel.com, vladimir.medvedkin@intel.com, honnappa.nagarahalli@arm.com, roretzla@linux.microsoft.com, Konstantin Ananyev Subject: [RFC 4/6] hash: remove VLA warnings Date: Thu, 18 Apr 2024 11:33:12 +0100 Message-Id: <20240418103314.40705-5-konstantin.v.ananyev@yandex.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240418103314.40705-1-konstantin.v.ananyev@yandex.ru> References: <20240418103314.40705-1-konstantin.v.ananyev@yandex.ru> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Konstantin Ananyev 1) ./lib/hash/rte_cuckoo_hash.c:2362:9: warning: ISO C90 forbids variable length array ‘positions’ [-Wvla] 2) ../lib/hash/rte_cuckoo_hash.c:2478:9: warning: ISO C90 forbids variable length array ‘positions’ [-Wvla] Both rte_hash_lookup_bulk_data() and rte_hash_lookup_with_hash_bulk_data() expect @num_keys <= RTE_HASH_LOOKUP_BULK_MAX. So, for both cases it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev Acked-by: Morten Brørup --- lib/hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf94645f6..82b74bda18 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -2359,7 +2359,7 @@ rte_hash_lookup_bulk_data(const struct rte_hash *h, const void **keys, (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask, data); @@ -2475,7 +2475,7 @@ rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h, (num_keys > RTE_HASH_LOOKUP_BULK_MAX) || (hit_mask == NULL)), -EINVAL); - int32_t positions[num_keys]; + int32_t positions[RTE_HASH_LOOKUP_BULK_MAX]; __rte_hash_lookup_with_hash_bulk(h, keys, sig, num_keys, positions, hit_mask, data);