Fix MISRA 8.2 violations (#675)

* Fix violation 8.2

* Update cppcheck

* Remove inline suppressions

* Change source to upstream
This commit is contained in:
Igor 2021-06-30 17:47:41 -07:00 committed by GitHub
parent 35b9df4643
commit b2d28a7123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 25 deletions

View File

@ -50,10 +50,10 @@ RUN pyenv install 3.8.5 && \
pip install --no-cache-dir -r /tmp/requirements.txt
RUN cd /tmp && \
git clone https://github.com/commaai/cppcheck.git && \
git clone https://github.com/danmar/cppcheck.git && \
cd cppcheck && \
git fetch && \
git checkout b440734ba7bda34c9d4e3cd2d9c26dc2303db542 && \
git checkout e1cff1d1ef92f6a1c6962e0e4153b7353ccad04c && \
FILESDIR=/usr/share/cppcheck make -j4 install
RUN cd /tmp && \

View File

@ -72,8 +72,6 @@ int can_err_cnt = 0;
int can_overflow_cnt = 0;
// ********************* interrupt safe queue *********************
// FIXME:
// cppcheck-suppress misra-c2012-8.2
bool can_pop(can_ring *q, CAN_FIFOMailBox_TypeDef *elem) {
bool ret = 0;
@ -294,8 +292,6 @@ void can_sce(CAN_TypeDef *CAN) {
}
// ***************************** CAN *****************************
// FIXME:
// cppcheck-suppress misra-c2012-8.2
void process_can(uint8_t can_number) {
if (can_number != 0xffU) {
@ -437,8 +433,7 @@ void CAN2_SCE_IRQ_Handler(void) { can_sce(CAN2); }
void CAN3_TX_IRQ_Handler(void) { process_can(2); }
void CAN3_RX0_IRQ_Handler(void) { can_rx(2); }
void CAN3_SCE_IRQ_Handler(void) { can_sce(CAN3); }
// FIXME:
// cppcheck-suppress misra-c2012-8.2
bool can_tx_check_min_slots_free(uint32_t min) {
return
(can_slots_empty(&can_tx1_q) >= min) &&
@ -446,8 +441,7 @@ bool can_tx_check_min_slots_free(uint32_t min) {
(can_slots_empty(&can_tx3_q) >= min) &&
(can_slots_empty(&can_txgmlan_q) >= min);
}
// FIXME:
// cppcheck-suppress misra-c2012-8.2
void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx_hook) {
if (skip_tx_hook || safety_tx_hook(to_push) != 0) {
if (bus_number < BUS_MAX) {
@ -463,13 +457,11 @@ void can_send(CAN_FIFOMailBox_TypeDef *to_push, uint8_t bus_number, bool skip_tx
}
}
}
// FIXME:
// cppcheck-suppress misra-c2012-8.2
void can_set_forwarding(int from, int to) {
can_forwarding[from] = to;
}
// FIXME:
// cppcheck-suppress misra-c2012-8.2
bool can_init(uint8_t can_number) {
bool ret = false;

View File

@ -270,8 +270,7 @@ void uart_set_baud(USART_TypeDef *u, unsigned int baud) {
u->BRR = __USART_BRR(24000000U, baud);
}
}
// FIXME:
// cppcheck-suppress misra-c2012-8.2
void uart_init(uart_ring *q, int baud) {
// Register interrupts (max data rate: 115200 baud)
if(q->uart == USART1){
@ -316,8 +315,6 @@ void uart_init(uart_ring *q, int baud) {
}
// ************************* Low-level buffer functions *************************
// FIXME:
// cppcheck-suppress misra-c2012-8.2
bool getc(uart_ring *q, char *elem) {
bool ret = false;
@ -347,8 +344,7 @@ bool injectc(uart_ring *q, char elem) {
return ret;
}
// FIXME:
// cppcheck-suppress misra-c2012-8.2
bool putc(uart_ring *q, char elem) {
bool ret = false;
uint16_t next_w_ptr;
@ -442,8 +438,7 @@ void puth2(unsigned int i) {
putch(c[(i >> (unsigned int)(pos)) & 0xFU]);
}
}
// FIXME:
// cppcheck-suppress misra-c2012-8.2
void hexdump(const void *a, int l) {
if (a != NULL) {
for (int i=0; i < l; i++) {

View File

@ -951,7 +951,7 @@ void usb_irqhandler(void) {
//USBx->GINTMSK = 0xFFFFFFFF & ~(USB_OTG_GINTMSK_NPTXFEM | USB_OTG_GINTMSK_PTXFEM | USB_OTG_GINTSTS_SOF | USB_OTG_GINTSTS_EOPF);
}
void usb_outep3_resume_if_paused() {
void usb_outep3_resume_if_paused(void) {
ENTER_CRITICAL();
if (!outep3_processing && (USBx_OUTEP(3)->DOEPCTL & USB_OTG_DOEPCTL_NAKSTS) != 0) {
USBx_OUTEP(3)->DOEPTSIZ = (1U << 19) | 0x40U;

View File

@ -242,13 +242,13 @@ void usb_cb_ep3_out(void *usbdata, int len, bool hardwired) {
}
}
void usb_cb_ep3_out_complete() {
void usb_cb_ep3_out_complete(void) {
if (can_tx_check_min_slots_free(MAX_CAN_MSGS_PER_BULK_TRANSFER)) {
usb_outep3_resume_if_paused();
}
}
void usb_cb_enumeration_complete() {
void usb_cb_enumeration_complete(void) {
puts("USB enumeration complete\n");
is_enumerated = 1;
}