fw: Initialize automatic variables

This commit is contained in:
Michael Cardell Widerkrantz 2023-03-16 13:51:24 +01:00
parent 226bcbaed1
commit 1f10c8e2db
No known key found for this signature in database
GPG Key ID: D3DB3DDF57E704E5
2 changed files with 9 additions and 9 deletions

View File

@ -93,9 +93,9 @@ static void compute_cdi(const uint8_t digest[32], const uint8_t use_uss,
const uint8_t uss[32]) const uint8_t uss[32])
{ {
uint32_t local_cdi[8]; uint32_t local_cdi[8];
blake2s_ctx secure_ctx; blake2s_ctx secure_ctx = {0};
uint32_t rnd_sleep; uint32_t rnd_sleep = 0;
int blake2err; int blake2err = 0;
// Prepare to sleep a random number of cycles before reading out UDS // Prepare to sleep a random number of cycles before reading out UDS
*timer_prescaler = 1; *timer_prescaler = 1;
@ -250,7 +250,7 @@ static enum state loading_commands(const struct frame_header *hdr,
struct context *ctx) struct context *ctx)
{ {
uint8_t rsp[CMDLEN_MAXBYTES] = {0}; uint8_t rsp[CMDLEN_MAXBYTES] = {0};
int nbytes; int nbytes = 0;
switch (cmd[0]) { switch (cmd[0]) {
case FW_CMD_LOAD_APP_DATA: case FW_CMD_LOAD_APP_DATA:
@ -380,8 +380,8 @@ static void scramble_ram()
int main() int main()
{ {
struct context ctx = {0}; struct context ctx = {0};
struct frame_header hdr; struct frame_header hdr = {0};
uint8_t cmd[CMDLEN_MAXBYTES]; uint8_t cmd[CMDLEN_MAXBYTES] = {0};
enum state state = FW_STATE_INITIAL; enum state state = FW_STATE_INITIAL;
print_hw_version(); print_hw_version();

View File

@ -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) 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; *led = (state == FW_STATE_LOADING) ? LED_BLACK : LED_WHITE;
in = readbyte(); in = readbyte();
@ -91,8 +91,8 @@ int parseframe(uint8_t b, struct frame_header *hdr)
// following data in buf // following data in buf
void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf) void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf)
{ {
size_t nbytes; size_t nbytes = 0;
enum cmdlen len; // length covering (rspcode + length of buf) enum cmdlen len = 0; // length covering (rspcode + length of buf)
switch (rspcode) { switch (rspcode) {
case FW_RSP_NAME_VERSION: case FW_RSP_NAME_VERSION: