Message ID | 1461782170-9154-1-git-send-email-bill.fischofer@linaro.org |
---|---|
State | Accepted |
Commit | 6e1e7f1b14889ac314819c524e1fc8744a143baa |
Headers | show |
On 04/27/16 21:36, Bill Fischofer wrote: > Add an additional cast to avoid compile errors in 32-bit mode > > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> > --- > test/validation/packet/packet.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c > index 4bae4d8..654fe0e 100644 > --- a/test/validation/packet/packet.c > +++ b/test/validation/packet/packet.c > @@ -1172,7 +1172,7 @@ void packet_test_align(void) > pkt_data = odp_packet_offset(pkt, 0, &seg_len, NULL); > offset = seg_len - 5; > pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); > - if ((uint64_t)pkt_data % max_align == 0) { > + if ((uint64_t)(uintptr_t)pkt_data % max_align == 0) { Does only one cast to uintptr_t work here? Maxim. > offset--; > pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); > } > @@ -1184,7 +1184,7 @@ void packet_test_align(void) > CU_ASSERT(odp_packet_len(pkt) == pkt_len); > _packet_compare_offset(pkt, offset, segmented_test_packet, offset, > aligned_seglen); > - CU_ASSERT((uint64_t)aligned_data % max_align == 0); > + CU_ASSERT((uint64_t)(uintptr_t)aligned_data % max_align == 0); > > odp_packet_free(pkt); > }
On Wed, Apr 27, 2016 at 1:57 PM, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > On 04/27/16 21:36, Bill Fischofer wrote: > >> Add an additional cast to avoid compile errors in 32-bit mode >> >> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> >> --- >> test/validation/packet/packet.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/test/validation/packet/packet.c >> b/test/validation/packet/packet.c >> index 4bae4d8..654fe0e 100644 >> --- a/test/validation/packet/packet.c >> +++ b/test/validation/packet/packet.c >> @@ -1172,7 +1172,7 @@ void packet_test_align(void) >> pkt_data = odp_packet_offset(pkt, 0, &seg_len, NULL); >> offset = seg_len - 5; >> pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); >> - if ((uint64_t)pkt_data % max_align == 0) { >> + if ((uint64_t)(uintptr_t)pkt_data % max_align == 0) { >> > Does only one cast to uintptr_t work here? > uintptr_t has type pointer to unsigned integer. Since that has an implied size, I'm not sure if the arithmetic would scale things according to C type rules. I'm just trying to check the value of the address, so treating the whole thing as a uint64_t seems safest. > > Maxim. > > offset--; >> pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); >> } >> @@ -1184,7 +1184,7 @@ void packet_test_align(void) >> CU_ASSERT(odp_packet_len(pkt) == pkt_len); >> _packet_compare_offset(pkt, offset, segmented_test_packet, offset, >> aligned_seglen); >> - CU_ASSERT((uint64_t)aligned_data % max_align == 0); >> + CU_ASSERT((uint64_t)(uintptr_t)aligned_data % max_align == 0); >> odp_packet_free(pkt); >> } >> > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/lng-odp >
I just checked that with one cast code cleanly compiles. Cast to uint64_t does not nothing bad, but it's not needed. As discussed I will modify patch on apply and remove case to uint64_t. Maxim. On 04/27/16 22:04, Bill Fischofer wrote: > > > On Wed, Apr 27, 2016 at 1:57 PM, Maxim Uvarov <maxim.uvarov@linaro.org > <mailto:maxim.uvarov@linaro.org>> wrote: > > On 04/27/16 21:36, Bill Fischofer wrote: > > Add an additional cast to avoid compile errors in 32-bit mode > > Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org > <mailto:bill.fischofer@linaro.org>> > --- > test/validation/packet/packet.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/test/validation/packet/packet.c > b/test/validation/packet/packet.c > index 4bae4d8..654fe0e 100644 > --- a/test/validation/packet/packet.c > +++ b/test/validation/packet/packet.c > @@ -1172,7 +1172,7 @@ void packet_test_align(void) > pkt_data = odp_packet_offset(pkt, 0, &seg_len, NULL); > offset = seg_len - 5; > pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); > - if ((uint64_t)pkt_data % max_align == 0) { > + if ((uint64_t)(uintptr_t)pkt_data % max_align == 0) { > > Does only one cast to uintptr_t work here? > > > uintptr_t has type pointer to unsigned integer. Since that has an > implied size, I'm not sure if the arithmetic would scale things > according to C type rules. I'm just trying to check the value of the > address, so treating the whole thing as a uint64_t seems safest. > > > Maxim. > > offset--; > pkt_data = odp_packet_offset(pkt, offset, > &seg_len, NULL); > } > @@ -1184,7 +1184,7 @@ void packet_test_align(void) > CU_ASSERT(odp_packet_len(pkt) == pkt_len); > _packet_compare_offset(pkt, offset, > segmented_test_packet, offset, > aligned_seglen); > - CU_ASSERT((uint64_t)aligned_data % max_align == 0); > + CU_ASSERT((uint64_t)(uintptr_t)aligned_data % > max_align == 0); > odp_packet_free(pkt); > } > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> > https://lists.linaro.org/mailman/listinfo/lng-odp > >
diff --git a/test/validation/packet/packet.c b/test/validation/packet/packet.c index 4bae4d8..654fe0e 100644 --- a/test/validation/packet/packet.c +++ b/test/validation/packet/packet.c @@ -1172,7 +1172,7 @@ void packet_test_align(void) pkt_data = odp_packet_offset(pkt, 0, &seg_len, NULL); offset = seg_len - 5; pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); - if ((uint64_t)pkt_data % max_align == 0) { + if ((uint64_t)(uintptr_t)pkt_data % max_align == 0) { offset--; pkt_data = odp_packet_offset(pkt, offset, &seg_len, NULL); } @@ -1184,7 +1184,7 @@ void packet_test_align(void) CU_ASSERT(odp_packet_len(pkt) == pkt_len); _packet_compare_offset(pkt, offset, segmented_test_packet, offset, aligned_seglen); - CU_ASSERT((uint64_t)aligned_data % max_align == 0); + CU_ASSERT((uint64_t)(uintptr_t)aligned_data % max_align == 0); odp_packet_free(pkt); }
Add an additional cast to avoid compile errors in 32-bit mode Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org> --- test/validation/packet/packet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)