misra21.15 (#2030)

* cast

* remove suppression

* make it more explicit
This commit is contained in:
Maxime Desroches 2024-09-19 10:35:11 -07:00 committed by GitHub
parent ae8ef1f71a
commit ed831773ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 7 deletions

View File

@ -38,10 +38,10 @@ int comms_can_read(uint8_t *data, uint32_t max_len) {
while ((pos < max_len) && can_pop(&can_rx_q, &can_packet)) {
uint32_t pckt_len = CANPACKET_HEAD_SIZE + dlc_to_len[can_packet.data_len_code];
if ((pos + pckt_len) <= max_len) {
(void)memcpy(&data[pos], &can_packet, pckt_len);
(void)memcpy(&data[pos], (uint8_t*)&can_packet, pckt_len);
pos += pckt_len;
} else {
(void)memcpy(&data[pos], &can_packet, max_len - pos);
(void)memcpy(&data[pos], (uint8_t*)&can_packet, max_len - pos);
can_read_buffer.ptr += pckt_len - (max_len - pos);
// cppcheck-suppress objectIndex
(void)memcpy(can_read_buffer.data, &((uint8_t*)&can_packet)[(max_len - pos)], can_read_buffer.ptr);
@ -69,7 +69,7 @@ void comms_can_write(const uint8_t *data, uint32_t len) {
pos += can_write_buffer.tail_size;
// send out
(void)memcpy(&to_push, can_write_buffer.data, can_write_buffer.ptr);
(void)memcpy((uint8_t*)&to_push, can_write_buffer.data, can_write_buffer.ptr);
can_send(&to_push, to_push.bus, false);
// reset overflow buffer
@ -90,7 +90,7 @@ void comms_can_write(const uint8_t *data, uint32_t len) {
uint32_t pckt_len = CANPACKET_HEAD_SIZE + dlc_to_len[(data[pos] >> 4U)];
if ((pos + pckt_len) <= len) {
CANPacket_t to_push = {0};
(void)memcpy(&to_push, &data[pos], pckt_len);
(void)memcpy((uint8_t*)&to_push, &data[pos], pckt_len);
can_send(&to_push, to_push.bus, false);
pos += pckt_len;
} else {

View File

@ -153,7 +153,7 @@ void spi_rx_done(void) {
if (spi_endpoint == 0U) {
if (spi_data_len_mosi >= sizeof(ControlPacket_t)) {
ControlPacket_t ctrl = {0};
(void)memcpy(&ctrl, &spi_buf_rx[SPI_HEADER_SIZE], sizeof(ControlPacket_t));
(void)memcpy((uint8_t*)&ctrl, &spi_buf_rx[SPI_HEADER_SIZE], sizeof(ControlPacket_t));
response_len = comms_control_handler(&ctrl, &spi_buf_tx[3]);
response_ack = true;
} else {

View File

@ -117,7 +117,7 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
can_health[req->param1].brs_enabled = bus_config[req->param1].brs_enabled;
can_health[req->param1].canfd_non_iso = bus_config[req->param1].canfd_non_iso;
resp_len = sizeof(can_health[req->param1]);
(void)memcpy(resp, &can_health[req->param1], resp_len);
(void)memcpy(resp, (uint8_t*)(&can_health[req->param1]), resp_len);
}
break;
// **** 0xc3: fetch MCU UID

View File

@ -21,4 +21,3 @@ unusedFunction:*/interrupt_handlers*.h
misra-c2012-2.5 # unused macros. a few legit, rest aren't common between F4/H7 builds. should we do this in the unusedFunction pass?
misra-c2012-8.7
misra-c2012-8.4
misra-c2012-21.15