From 2f0e146d0bef3a3f8e57dcd9723503fd0f31a8f5 Mon Sep 17 00:00:00 2001 From: Philip Vedin Date: Thu, 22 Feb 2024 13:21:56 +0100 Subject: [PATCH] ports: Remove side effects from CC_ASSERT calls Since p-net may be compiled without asserts (e.g. release builds for STM32Cube), it could be the case that expressions with side effects were not evaluated; this would cause incorrect behaviour. While the rt-kernel port does not use CC_ASSERT, it has also been changed in the same manner for consistency. --- src/ports/STM32Cube/pnal.c | 4 +++- src/ports/iMX8M/pnal.c | 4 +++- src/ports/rt-kernel/pnal.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ports/STM32Cube/pnal.c b/src/ports/STM32Cube/pnal.c index 7f7d3f6e..8b21315b 100644 --- a/src/ports/STM32Cube/pnal.c +++ b/src/ports/STM32Cube/pnal.c @@ -299,7 +299,9 @@ pnal_buf_t * pnal_buf_alloc (uint16_t length) void pnal_buf_free (pnal_buf_t * p) { - CC_ASSERT (pbuf_free (p) == 1); + uint8_t deallocated = pbuf_free (p); + (void)deallocated; + CC_ASSERT (deallocated == 1); } uint8_t pnal_buf_header (pnal_buf_t * p, int16_t header_size_increment) diff --git a/src/ports/iMX8M/pnal.c b/src/ports/iMX8M/pnal.c index cf1efaad..593a933e 100644 --- a/src/ports/iMX8M/pnal.c +++ b/src/ports/iMX8M/pnal.c @@ -176,7 +176,9 @@ pnal_buf_t * pnal_buf_alloc (uint16_t length) void pnal_buf_free (pnal_buf_t * p) { - CC_ASSERT (pbuf_free (p) == 1); + uint8_t deallocated = pbuf_free (p); + (void)deallocated; + CC_ASSERT (deallocated == 1); } uint8_t pnal_buf_header (pnal_buf_t * p, int16_t header_size_increment) diff --git a/src/ports/rt-kernel/pnal.c b/src/ports/rt-kernel/pnal.c index 214ef7bf..5abf1f0c 100644 --- a/src/ports/rt-kernel/pnal.c +++ b/src/ports/rt-kernel/pnal.c @@ -369,7 +369,9 @@ pnal_buf_t * pnal_buf_alloc (uint16_t length) void pnal_buf_free (pnal_buf_t * p) { - ASSERT (pbuf_free (p) == 1); + uint8_t deallocated = pbuf_free (p); + (void)deallocated; + ASSERT (deallocated == 1); } uint8_t pnal_buf_header (pnal_buf_t * p, int16_t header_size_increment)