RE: [PATCH 1/3] eal: fix pointer arithmetic with an expression argument

2022-08-22 Thread Morten Brørup
> From: Dmitry Kozlyuk [mailto:dmitry.kozl...@gmail.com] > Sent: Sunday, 21 August 2022 22.50 > > RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly > if "ptr" was an expression: > > uint32_t arr[3]; > > RTE_PTR_SUB(arr + 1, sizeof(arr[0])); > // expected: (uint32_t *)(

[PATCH 1/3] eal: fix pointer arithmetic with an expression argument

2022-08-21 Thread Dmitry Kozlyuk
RTE_PTR_SUB(ptr, x) and RTE_PTR_ALIGN_FLOOR() worked incorrectly if "ptr" was an expression: uint32_t arr[3]; RTE_PTR_SUB(arr + 1, sizeof(arr[0])); // expected: (uint32_t *)((uintptr_t)(arr + 1) - 4) == arr // actual: (uint32_t *)((uintptr_t) arr + 1 - 4) != arr RTE_PTR_AL