Skip to content

Commit

Permalink
cppcheck: misra-c2012-11.6
Browse files Browse the repository at this point in the history
Avoid casting between pointer to void and an arithmetic type.
Refactor bootloader address handling for easier understanding.
  • Loading branch information
dzid26 committed May 26, 2024
1 parent b73dfb9 commit 478a3e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion board/early_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
extern void *g_pfnVectors;
extern uint32_t enter_bootloader_mode;

typedef void (*bootloader_fcn)(void);
typedef bootloader_fcn *bootloader_fcn_ptr;

void jump_to_bootloader(void) {
// do enter bootloader
enter_bootloader_mode = 0;
void (*bootloader)(void) = (void (*)(void)) (*((uint32_t *)BOOTLOADER_ADDRESS));

// retrieve bootloader function pointer that is stored at BOOTLOADER_ADDRESS
bootloader_fcn_ptr bootloader_ptr = (bootloader_fcn_ptr)BOOTLOADER_ADDRESS;
// retrieve actual function address from bootloader pointer
bootloader_fcn bootloader = *bootloader_ptr;

// jump to bootloader
enable_interrupts();
Expand Down

0 comments on commit 478a3e9

Please sign in to comment.