From 1cce79a3028ec2a9217259fed02299f857db653a Mon Sep 17 00:00:00 2001 From: Marc Finet Date: Fri, 10 Sep 2021 18:19:08 +0200 Subject: [PATCH] debug: cast buffer to uint8 on log To: - deref an uint8_t (otherwise the value could be an uint32_t) - fix deref size, since with pass the sizeof. For a pointer to a single struct with overflow the struct. Typical usage: ```c struct { uint32_t x; uint32_t y; uint8_t data[10]; } foo; LOG_BUFFER(LVL_DEBUG, &foo, sizeof(foo)); ``` --- util/debug_log.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/debug_log.h b/util/debug_log.h index a2224667..219cbcf0 100644 --- a/util/debug_log.h +++ b/util/debug_log.h @@ -195,7 +195,7 @@ if(((uint8_t) level) <= ((uint8_t) DEBUG_LOG_MAX_LEVEL)) { \ for (uint8_t i = 0; i < size; i++) \ { \ - Print_Log("%02X ", buffer[i]); \ + Print_Log("%02X ", ((uint8_t *)buffer)[i]); \ if ((i & 0xF) == 0xF && i != (uint8_t)(size-1)) \ { \ Print_Log("\n"); \