From patchwork Thu Apr 18 10:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Konstantin Ananyev X-Patchwork-Id: 139492 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 0F29843E9F; Thu, 18 Apr 2024 12:34:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8EEE40A84; Thu, 18 Apr 2024 12:33:50 +0200 (CEST) Received: from forward500a.mail.yandex.net (forward500a.mail.yandex.net [178.154.239.80]) by mails.dpdk.org (Postfix) with ESMTP id 7A34940A7F for ; Thu, 18 Apr 2024 12:33:49 +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 491B56164B; Thu, 18 Apr 2024 13:33:49 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-22.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id GXCBSvCo7Ko0-TsSwqi9x; Thu, 18 Apr 2024 13:33:48 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1713436428; bh=Bzwk20NQQV3OwSPoK0NnvgCo8FXFQX/kl8TVMRycArY=; h=Cc:Message-Id:References:Date:In-Reply-To:Subject:To:From; b=TgqcfraeD1MQ2vcXsP4sB8q2pLtgRboIZDsNbBwcSwR/sGJ1RgK9lsbyQYggvxwb0 qy3xQiyfhXwE4IheBVt1uj7kWyndiHGXaWZX9h1PmFcY9UIfDKmzj4uqN+0CCtgQsC LYF5gXELOyRmDneHRwNnhG4rQG3M4GaUkyxBjkE0= 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 5/6] hash/thash: remove VLA warnings Date: Thu, 18 Apr 2024 11:33:13 +0100 Message-Id: <20240418103314.40705-6-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_thash.c:774:9: warning: ISO C90 forbids variable length array ‘tmp_tuple’ [-Wvla] From my understanding, tuple size here should never exceed sizeof(union rte_thash_tuple), so it should be safe to replace VLA with fixed size array. Signed-off-by: Konstantin Ananyev Acked-by: Morten Brørup --- lib/hash/rte_thash.c | 2 +- lib/hash/rte_thash.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c index 68f653fa3d..e28d423172 100644 --- a/lib/hash/rte_thash.c +++ b/lib/hash/rte_thash.c @@ -771,7 +771,7 @@ rte_thash_adjust_tuple(struct rte_thash_ctx *ctx, uint32_t desired_value, unsigned int attempts, rte_thash_check_tuple_t fn, void *userdata) { - uint32_t tmp_tuple[tuple_len / sizeof(uint32_t)]; + uint32_t tmp_tuple[RTE_THASH_MAX_L4_LEN]; unsigned int i, j, ret = 0; uint32_t hash, adj_bits; const uint8_t *hash_key; diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h index 30b657e67a..322fe3af66 100644 --- a/lib/hash/rte_thash.h +++ b/lib/hash/rte_thash.h @@ -108,6 +108,14 @@ union rte_thash_tuple { struct rte_ipv6_tuple v6; }; +/** + * maximum length in dwords of input tuple to + * calculate hash of ipv(4|6) header + + * transport header + */ +#define RTE_THASH_MAX_L4_LEN \ + ((sizeof(union rte_thash_tuple)) / sizeof(uint32_t)) + /** * Prepare special converted key to use with rte_softrss_be() * @param orig