From 2d63dd4b5b01df2406cda71ee1fb08968b14fd0a Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Mon, 17 Jun 2013 15:46:26 +1200 Subject: [PATCH] Fix register array sizes. --- src/cortexm.c | 2 +- src/gdb_main.c | 8 ++++---- src/lpc43xx.c | 2 +- src/nxp_tgt.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cortexm.c b/src/cortexm.c index 130f683..7819598 100644 --- a/src/cortexm.c +++ b/src/cortexm.c @@ -667,7 +667,7 @@ static int cortexm_fault_unwind(struct target_s *target) * for a configurable fault to avoid catching core resets */ if((hfsr & CORTEXM_HFSR_FORCED) || cfsr) { /* Unwind exception */ - uint32_t regs[target->regs_size]; + uint32_t regs[target->regs_size / 4]; uint32_t stack[8]; uint32_t retcode, framesize; /* Read registers for post-exception stack pointer */ diff --git a/src/gdb_main.c b/src/gdb_main.c index 69d5ed1..bd27d48 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -88,8 +88,8 @@ gdb_main(void) /* Implementation of these is mandatory! */ case 'g': { /* 'g': Read general registers */ ERROR_IF_NO_TARGET(); - uint32_t arm_regs[cur_target->regs_size]; - target_regs_read(cur_target, (void*)arm_regs); + uint8_t arm_regs[cur_target->regs_size]; + target_regs_read(cur_target, arm_regs); gdb_putpacket(hexify(pbuf, (void*)arm_regs, cur_target->regs_size), cur_target->regs_size * 2); break; } @@ -111,8 +111,8 @@ gdb_main(void) } case 'G': { /* 'G XX': Write general registers */ ERROR_IF_NO_TARGET(); - uint32_t arm_regs[cur_target->regs_size]; - unhexify((void*)arm_regs, &pbuf[1], cur_target->regs_size); + uint8_t arm_regs[cur_target->regs_size]; + unhexify(arm_regs, &pbuf[1], cur_target->regs_size); target_regs_write(cur_target, arm_regs); gdb_putpacketz("OK"); break; diff --git a/src/lpc43xx.c b/src/lpc43xx.c index fc843c6..200a8a4 100644 --- a/src/lpc43xx.c +++ b/src/lpc43xx.c @@ -313,7 +313,7 @@ static int32_t sector_number(uint32_t addr) static void lpc43xx_iap_call(struct target_s *target, struct flash_param *param, unsigned param_len) { - uint32_t regs[target->regs_size]; + uint32_t regs[target->regs_size / 4]; uint32_t iap_entry; target_mem_read_words(target, &iap_entry, IAP_ENTRYPOINT_LOCATION, sizeof(iap_entry)); diff --git a/src/nxp_tgt.c b/src/nxp_tgt.c index f8ddf2a..ccb2cc6 100644 --- a/src/nxp_tgt.c +++ b/src/nxp_tgt.c @@ -116,7 +116,7 @@ lpc11xx_probe(struct target_s *target) static void lpc11x_iap_call(struct target_s *target, struct flash_param *param, unsigned param_len) { - uint32_t regs[target->regs_size]; + uint32_t regs[target->regs_size / 4]; /* fill out the remainder of the parameters and copy the structure to RAM */ param->opcodes[0] = 0xbe00;