Skip to content

Commit

Permalink
[style] Protect macro + missing parentheses (MISRA style) + const and
Browse files Browse the repository at this point in the history
volatile missing qualifiers.
  • Loading branch information
rben-dev committed May 11, 2019
1 parent f5889f5 commit d0ad1cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/default_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ stack_frame_t *exti_handler(stack_frame_t * stack_frame)
}
}
break;
default:
break;
}
return stack_frame;
}
Expand All @@ -108,8 +110,8 @@ stack_frame_t *exti_handler(stack_frame_t * stack_frame)

stack_frame_t *HardFault_Handler(stack_frame_t * frame)
{
uint32_t cfsr = *((uint32_t *) r_CORTEX_M_SCB_CFSR);
uint32_t hfsr = *((uint32_t *) r_CORTEX_M_SCB_HFSR);
uint32_t cfsr = *((volatile uint32_t *) r_CORTEX_M_SCB_CFSR);
uint32_t hfsr = *((volatile uint32_t *) r_CORTEX_M_SCB_HFSR);
uint32_t *p;
int i;
#ifdef KERNEL
Expand Down
12 changes: 6 additions & 6 deletions src/flash_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@
/* return true if the the address is in the flash memory */
#if CONFIG_USR_DRV_FLASH_1M
# if CONFIG_USR_DRV_FLASH_DUAL_BANK
# define IS_IN_FLASH(addr) (addr >= FLASH_SECTOR_0) && \
(addr <= FLASH_SECTOR_19_END)
# define IS_IN_FLASH(addr) ((addr) >= FLASH_SECTOR_0) && \
((addr) <= FLASH_SECTOR_19_END)
# else
# define IS_IN_FLASH(addr) (addr >= FLASH_SECTOR_0) && \
(addr <= FLASH_SECTOR_11_END)
# define IS_IN_FLASH(addr) ((addr) >= FLASH_SECTOR_0) && \
((addr) <= FLASH_SECTOR_11_END)
# endif
#elif CONFIG_USR_DRV_FLASH_2M
# define IS_IN_FLASH(addr) (addr >= FLASH_SECTOR_0) && \
(addr <= FLASH_SECTOR_23_END)
# define IS_IN_FLASH(addr) ((addr) >= FLASH_SECTOR_0) && \
((addr) <= FLASH_SECTOR_23_END)
#else
# error "Unkown flash size!"
#endif
Expand Down
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void hexdump(const uint8_t *bin, uint32_t len)
{
for (uint32_t i = 0; i < len; i++) {
dbg_log("%x ", bin[i]);
if (i % 16 == 0 && i != 0) {
if ((i % 16 == 0) && (i != 0)) {
dbg_log("\n");
}
dbg_flush();
Expand Down Expand Up @@ -217,7 +217,7 @@ int main(void)
start = soc_dwt_getcycles() / 168000;
do {
stop = soc_dwt_getcycles() / 168000;
} while (stop - start < 1000); // < 1s
} while ((stop - start) < 1000); // < 1s
dbg_log(".");
dbg_flush();
count--;
Expand Down Expand Up @@ -360,17 +360,17 @@ int main(void)
#endif
uint32_t crc = 0;
/* checking CRC32 header check */
crc = crc32((uint8_t*)fw, sizeof(t_firmware_signature) - sizeof(uint32_t) - SHA256_DIGEST_SIZE - EC_MAX_SIGLEN, 0xffffffff);
crc = crc32((const uint8_t*)fw, sizeof(t_firmware_signature) - sizeof(uint32_t) - SHA256_DIGEST_SIZE - EC_MAX_SIGLEN, 0xffffffff);
crc = crc32((uint8_t*)&buf, sizeof(uint32_t), crc);
crc = crc32((uint8_t*)fw->fw_sig.hash, SHA256_DIGEST_SIZE, crc);
crc = crc32((const uint8_t*)fw->fw_sig.hash, SHA256_DIGEST_SIZE, crc);
for (uint32_t i = 0; i < EC_MAX_SIGLEN; ++i) {
crc = crc32((uint8_t*)&buf, sizeof(uint8_t), crc);
}
/* check CRC of padding (fill field) */
crc = crc32((uint8_t*)fw->fill, SHR_SECTOR_SIZE - sizeof(t_firmware_signature), crc);
crc = crc32((const uint8_t*)fw->fill, SHR_SECTOR_SIZE - sizeof(t_firmware_signature), crc);
/* check CRC of bootable flag */
crc = crc32((uint8_t*)&fw->bootable, sizeof(uint32_t), crc);
crc = crc32((uint8_t*)&fw->fill2, SHR_SECTOR_SIZE - sizeof(uint32_t), crc);
crc = crc32((const uint8_t*)&fw->bootable, sizeof(uint32_t), crc);
crc = crc32((const uint8_t*)&fw->fill2, SHR_SECTOR_SIZE - sizeof(uint32_t), crc);

/* Double check for faults */
if (crc != fw->fw_sig.crc32) {
Expand Down

0 comments on commit d0ad1cc

Please sign in to comment.