[1/3] eal/riscv: fix xmm_t casting for C++

Message ID 20220609121701.716299-2-kda@semihalf.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series Fix xmm_t to rte_xmm_t scalar conversion |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stanislaw Kardach June 9, 2022, 12:16 p.m. UTC
  rte_xmm_t is a union type which wraps around xmm_t and maps its contents
to scalar structures. Since C++ has stricter type conversion rules than
C, the rte_xmm_t::x has to be used instead of C-casting.

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
---
 lib/eal/riscv/include/rte_vect.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

David Marchand June 13, 2022, 9:29 a.m. UTC | #1
On Thu, Jun 9, 2022 at 2:17 PM Stanislaw Kardach <kda@semihalf.com> wrote:
>
> rte_xmm_t is a union type which wraps around xmm_t and maps its contents
> to scalar structures. Since C++ has stricter type conversion rules than
> C, the rte_xmm_t::x has to be used instead of C-casting.
>

Fixes: f22e705ebf12 ("eal/riscv: support RISC-V architecture")

> Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
  

Patch

diff --git a/lib/eal/riscv/include/rte_vect.h b/lib/eal/riscv/include/rte_vect.h
index 4600521c20..2f97f437a2 100644
--- a/lib/eal/riscv/include/rte_vect.h
+++ b/lib/eal/riscv/include/rte_vect.h
@@ -41,8 +41,8 @@  vect_load_128(void *p)
 static inline xmm_t
 vect_and(xmm_t data, xmm_t mask)
 {
-	rte_xmm_t ret = (rte_xmm_t)data;
-	rte_xmm_t m = (rte_xmm_t)mask;
+	rte_xmm_t ret = {.x = data };
+	rte_xmm_t m = {.x = mask };
 	ret.u64[0] &= m.u64[0];
 	ret.u64[1] &= m.u64[1];
 	return ret.x;