From 1f10c8e2db10966d012301f83fe5a40fcf5a139d Mon Sep 17 00:00:00 2001 From: Michael Cardell Widerkrantz Date: Thu, 16 Mar 2023 13:51:24 +0100 Subject: [PATCH] fw: Initialize automatic variables --- hw/application_fpga/fw/tk1/main.c | 12 ++++++------ hw/application_fpga/fw/tk1/proto.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/application_fpga/fw/tk1/main.c b/hw/application_fpga/fw/tk1/main.c index c54fdc8..b022fa8 100644 --- a/hw/application_fpga/fw/tk1/main.c +++ b/hw/application_fpga/fw/tk1/main.c @@ -93,9 +93,9 @@ static void compute_cdi(const uint8_t digest[32], const uint8_t use_uss, const uint8_t uss[32]) { uint32_t local_cdi[8]; - blake2s_ctx secure_ctx; - uint32_t rnd_sleep; - int blake2err; + blake2s_ctx secure_ctx = {0}; + uint32_t rnd_sleep = 0; + int blake2err = 0; // Prepare to sleep a random number of cycles before reading out UDS *timer_prescaler = 1; @@ -250,7 +250,7 @@ static enum state loading_commands(const struct frame_header *hdr, struct context *ctx) { uint8_t rsp[CMDLEN_MAXBYTES] = {0}; - int nbytes; + int nbytes = 0; switch (cmd[0]) { case FW_CMD_LOAD_APP_DATA: @@ -380,8 +380,8 @@ static void scramble_ram() int main() { struct context ctx = {0}; - struct frame_header hdr; - uint8_t cmd[CMDLEN_MAXBYTES]; + struct frame_header hdr = {0}; + uint8_t cmd[CMDLEN_MAXBYTES] = {0}; enum state state = FW_STATE_INITIAL; print_hw_version(); diff --git a/hw/application_fpga/fw/tk1/proto.c b/hw/application_fpga/fw/tk1/proto.c index 104b9b7..458ba0c 100644 --- a/hw/application_fpga/fw/tk1/proto.c +++ b/hw/application_fpga/fw/tk1/proto.c @@ -24,7 +24,7 @@ uint8_t genhdr(uint8_t id, uint8_t endpoint, uint8_t status, enum cmdlen len) int readcommand(struct frame_header *hdr, uint8_t *cmd, int state) { - uint8_t in; + uint8_t in = 0; *led = (state == FW_STATE_LOADING) ? LED_BLACK : LED_WHITE; in = readbyte(); @@ -91,8 +91,8 @@ int parseframe(uint8_t b, struct frame_header *hdr) // following data in buf void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf) { - size_t nbytes; - enum cmdlen len; // length covering (rspcode + length of buf) + size_t nbytes = 0; + enum cmdlen len = 0; // length covering (rspcode + length of buf) switch (rspcode) { case FW_RSP_NAME_VERSION: