From 4303ae1387d91be82314945209ac0d2ff7199e46 Mon Sep 17 00:00:00 2001 From: Aryan <53595853+0x41head@users.noreply.github.com> Date: Wed, 28 Feb 2024 00:02:28 +0530 Subject: [PATCH 1/2] enable misra-c2012-10.6 (#1811) * misra-c2012-10.6 * fixed uninitialized data error * revert false positive * enable 10.6 * update install.sh * cleanup * bug fix * better fix ? --- board/drivers/usb.h | 6 +++--- tests/misra/install.sh | 2 +- tests/misra/suppressions.txt | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/board/drivers/usb.h b/board/drivers/usb.h index 1872dd5276..5ecbea2197 100644 --- a/board/drivers/usb.h +++ b/board/drivers/usb.h @@ -364,7 +364,7 @@ int current_int0_alt_setting = 0; void *USB_ReadPacket(void *dest, uint16_t len) { uint32_t *dest_copy = (uint32_t *)dest; - uint32_t count32b = (len + 3U) / 4U; + uint32_t count32b = ((uint32_t)len + 3U) / 4U; for (uint32_t i = 0; i < count32b; i++) { *dest_copy = USBx_DFIFO(0); @@ -379,9 +379,9 @@ void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) { hexdump(src, len); #endif - uint32_t numpacket = (len + (USBPACKET_MAX_SIZE - 1U)) / USBPACKET_MAX_SIZE; + uint32_t numpacket = ((uint32_t)len + (USBPACKET_MAX_SIZE - 1U)) / USBPACKET_MAX_SIZE; uint32_t count32b = 0; - count32b = (len + 3U) / 4U; + count32b = ((uint32_t)len + 3U) / 4U; // TODO: revisit this USBx_INEP(ep)->DIEPTSIZ = ((numpacket << 19) & USB_OTG_DIEPTSIZ_PKTCNT) | diff --git a/tests/misra/install.sh b/tests/misra/install.sh index a29b111176..ecc0b3f0d1 100755 --- a/tests/misra/install.sh +++ b/tests/misra/install.sh @@ -13,7 +13,7 @@ cd $CPPCHECK_DIR VERS="2.13.0" git fetch --all --tags git checkout $VERS -git cherry-pick -n f6b538e855f0bacea33c4074664628024ef39dc6 +git cherry-pick -n f6b538e855f0bacea33c4074664628024ef39dc6 b11b42087ff29569bc3740f5aa07eb6616ea4f63 #make clean make MATCHCOMPILTER=yes CXXFLAGS="-O2" -j8 diff --git a/tests/misra/suppressions.txt b/tests/misra/suppressions.txt index be4b0e0265..d5b14c836a 100644 --- a/tests/misra/suppressions.txt +++ b/tests/misra/suppressions.txt @@ -23,5 +23,4 @@ misra-c2012-1.2 # this is from the extensions (e.g. __typeof__) used in the MIN misra-c2012-2.5 misra-c2012-8.7 misra-c2012-8.4 -misra-c2012-10.6 misra-c2012-21.15 From ea156f7c628a371bea9a15a29f9068d5392534ba Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Wed, 28 Feb 2024 20:31:47 -0800 Subject: [PATCH 2/2] revert that for now --- board/stm32h7/clock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/stm32h7/clock.h b/board/stm32h7/clock.h index 7d65d080ec..a0ac01d0d9 100644 --- a/board/stm32h7/clock.h +++ b/board/stm32h7/clock.h @@ -21,11 +21,11 @@ void clock_init(void) { // Set power mode to direct SMPS power supply(depends on the board layout) #ifndef STM32H723 register_set(&(PWR->CR3), PWR_CR3_SMPSEN, 0xFU); // powered only by SMPS -#endif // Set VOS level (VOS3 to 170Mhz, VOS2 to 300Mhz, VOS1 to 400Mhz, VOS0 to 550Mhz) register_set(&(PWR->D3CR), PWR_D3CR_VOS_1 | PWR_D3CR_VOS_0, 0xC000U); //VOS1, needed for 80Mhz CAN FD while ((PWR->CSR1 & PWR_CSR1_ACTVOSRDY) == 0); while ((PWR->CSR1 & PWR_CSR1_ACTVOS) != (PWR->D3CR & PWR_D3CR_VOS)); // check that VOS level was actually set +#endif // Configure Flash ACR register LATENCY and WRHIGHFREQ (VOS0 range!) register_set(&(FLASH->ACR), FLASH_ACR_LATENCY_2WS | 0x20U, 0x3FU); // VOS2, AXI 100MHz-150MHz