From 8029e081535672dae582c7be6a8349cce0aa9c0e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 24 Jul 2023 00:54:12 +0200 Subject: [PATCH] cppchecker, make sure struct is initialized to zero --- client/src/comms.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/client/src/comms.c b/client/src/comms.c index 1422c42d3..7bd553f20 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -742,9 +742,21 @@ static size_t communication_delay(void) { bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning) { PacketResponseNG resp; - - if (response == NULL) + if (response == NULL) { response = &resp; + } + + // init to ZERO + resp.cmd = 0, + resp.length = 0, + resp.magic = 0, + resp.status = 0, + resp.crc = 0, + resp.ng = false, + resp.oldarg[0] = 0; + resp.oldarg[1] = 0; + resp.oldarg[2] = 0; + memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE); // Add delay depending on the communication channel & speed if (ms_timeout != (size_t) - 1) @@ -811,8 +823,21 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3 if (bytes == 0) return true; PacketResponseNG resp; - if (response == NULL) + if (response == NULL) { response = &resp; + } + + // init to ZERO + resp.cmd = 0, + resp.length = 0, + resp.magic = 0, + resp.status = 0, + resp.crc = 0, + resp.ng = false, + resp.oldarg[0] = 0; + resp.oldarg[1] = 0; + resp.oldarg[2] = 0; + memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE); // clear clearCommandBuffer();