All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	stable@dpdk.org, Yipeng Wang <yipeng1.wang@intel.com>,
	Sameh Gobriel <sameh.gobriel@intel.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
	Olivier Matz <olivier.matz@6wind.com>,
	Cyril Chemparathy <cchemparathy@ezchip.com>
Subject: [PATCH v2 1/5] test: fix jhash 32 bit key type
Date: Sun,  6 Sep 2026 10:09:54 -0700	[thread overview]
Message-ID: <20260906171142.3503868-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20260906171142.3503868-1-stephen@networkplumber.org>

verify_jhash_32bits() declares the key as an array of bytes, then
casts it to unaligned_uint32_t * to pass to rte_jhash_32b(), which
takes a const uint32_t *. Clang reports:

  passing 1-byte aligned argument to 4-byte aligned parameter 1 of
  'rte_jhash_32b' may result in an unaligned pointer access
  [-Walign-mismatch]

This already happens on armv8 aarch32, where unaligned types have
alignment 1, and will happen everywhere once that is true on all
architectures.

Declare the key as an array of uint32_t and drop the cast.

Fixes: 7621d6a8d0bd ("eal: add and use unaligned integer types")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_hash_functions.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c
index 70820d1f19..fdff304d2b 100644
--- a/app/test/test_hash_functions.c
+++ b/app/test/test_hash_functions.c
@@ -185,12 +185,12 @@ verify_precalculated_hash_func_tests(void)
 static int
 verify_jhash_32bits(void)
 {
-	unsigned i, j;
-	uint8_t key[64];
+	unsigned int i, j;
+	uint32_t key[16];
 	uint32_t hash, hash32;
 
-	for (i = 0; i < 64; i++)
-		key[i] = rand() & 0xff;
+	for (i = 0; i < RTE_DIM(key); i++)
+		key[i] = (uint32_t) rte_rand();
 
 	for (i = 0; i < RTE_DIM(hashtest_key_lens); i++) {
 		for (j = 0; j < RTE_DIM(hashtest_initvals); j++) {
@@ -199,9 +199,9 @@ verify_jhash_32bits(void)
 				hash = rte_jhash(key, hashtest_key_lens[i],
 						hashtest_initvals[j]);
 				/* Divide key length by 4 in rte_jhash for 32 bits */
-				hash32 = rte_jhash_32b((const unaligned_uint32_t *)key,
-						hashtest_key_lens[i] >> 2,
-						hashtest_initvals[j]);
+				hash32 = rte_jhash_32b(key,
+						       hashtest_key_lens[i] / sizeof(uint32_t),
+						       hashtest_initvals[j]);
 				if (hash != hash32) {
 					printf("rte_jhash returns different value (0x%x)"
 					       "than rte_jhash_32b (0x%x)\n",
-- 
2.53.0


  reply	other threads:[~2026-09-06 17:12 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 22:09 [RFC 0/3] eal: make unaligned types really unaligned Stephen Hemminger
2026-09-04 22:09 ` [RFC 1/3] eal: make unaligned " Stephen Hemminger
2026-09-04 22:09 ` [RFC 2/3] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-05 10:00   ` Morten Brørup
2026-09-04 22:09 ` [RFC 3/3] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger
2026-09-06 17:09 ` [PATCH v2 0/5] eal: RTE_PTR_ADD qualifiers and real unaligned types Stephen Hemminger
2026-09-06 17:09   ` Stephen Hemminger [this message]
2026-09-06 17:09   ` [PATCH v2 2/5] eal: RTE_PTR_ADD/SUB API improvements Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 3/5] eal: make unaligned really unaligned Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 4/5] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-06 17:09   ` [PATCH v2 5/5] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger
2026-09-06 20:14   ` [PATCH v2 0/5] eal: RTE_PTR_ADD qualifiers and real unaligned types Morten Brørup
2026-09-07 18:31 ` [PATCH v3 0/5] eal: RTE_PTR_ADD and fix " Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 1/5] test: fix jhash 32 bit key type Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 2/5] eal: RTE_PTR_ADD/SUB API improvements Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 3/5] eal: make unaligned really unaligned Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 4/5] net/mlx5: drop unnecessary STRICT_ALIGN Stephen Hemminger
2026-09-07 18:31   ` [PATCH v3 5/5] arm: remove no longer used RTE_ARCH_STRICT_ALIGN Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260906171142.3503868-2-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=bruce.richardson@intel.com \
    --cc=cchemparathy@ezchip.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=sameh.gobriel@intel.com \
    --cc=stable@dpdk.org \
    --cc=vladimir.medvedkin@intel.com \
    --cc=yipeng1.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.