Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cppcheck 2.14 #1951

Merged
merged 6 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions board/can_comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void comms_can_write(const uint8_t *data, uint32_t len) {
if (can_write_buffer.ptr != 0U) {
if (can_write_buffer.tail_size <= (len - pos)) {
// we have enough data to complete the buffer
CANPacket_t to_push;
CANPacket_t to_push = {0};
(void)memcpy(&can_write_buffer.data[can_write_buffer.ptr], &data[pos], can_write_buffer.tail_size);
can_write_buffer.ptr += can_write_buffer.tail_size;
pos += can_write_buffer.tail_size;
Expand All @@ -89,7 +89,7 @@ void comms_can_write(const uint8_t *data, uint32_t len) {
while (pos < len) {
uint32_t pckt_len = CANPACKET_HEAD_SIZE + dlc_to_len[(data[pos] >> 4U)];
if ((pos + pckt_len) <= len) {
CANPacket_t to_push;
CANPacket_t to_push = {0};
(void)memcpy(&to_push, &data[pos], pckt_len);
can_send(&to_push, to_push.bus, false);
pos += pckt_len;
Expand Down
6 changes: 3 additions & 3 deletions board/drivers/can_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ void can_set_forwarding(uint8_t from, uint8_t to) {

void ignition_can_hook(CANPacket_t *to_push) {
int bus = GET_BUS(to_push);
int addr = GET_ADDR(to_push);
int len = GET_LEN(to_push);

if (bus == 0) {
int addr = GET_ADDR(to_push);
int len = GET_LEN(to_push);

// GM exception
if ((addr == 0x1F1) && (len == 8)) {
// SystemPowerMode (2=Run, 3=Crank Request)
Expand Down
4 changes: 2 additions & 2 deletions board/drivers/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ uint16_t spi_data_len_miso;
uint16_t spi_checksum_error_count = 0;
bool spi_can_tx_ready = false;

const char version_text[] = "VERSION";
const unsigned char version_text[] = "VERSION";

#define SPI_HEADER_SIZE 7U

Expand Down Expand Up @@ -152,7 +152,7 @@ void spi_rx_done(void) {
if (checksum_valid) {
if (spi_endpoint == 0U) {
if (spi_data_len_mosi >= sizeof(ControlPacket_t)) {
ControlPacket_t ctrl;
ControlPacket_t ctrl = {0};
(void)memcpy(&ctrl, &spi_buf_rx[SPI_HEADER_SIZE], sizeof(ControlPacket_t));
response_len = comms_control_handler(&ctrl, &spi_buf_tx[3]);
response_ack = true;
Expand Down
7 changes: 6 additions & 1 deletion board/early_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
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));

bootloader_fcn_ptr bootloader_ptr = (bootloader_fcn_ptr)BOOTLOADER_ADDRESS;
bootloader_fcn bootloader = *bootloader_ptr;

// jump to bootloader
enable_interrupts();
Expand Down
2 changes: 1 addition & 1 deletion board/provision.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define PROVISION_CHUNK_LEN 0x20

const char unprovisioned_text[] = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff";
const unsigned char unprovisioned_text[] = "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff";

void get_provision_chunk(uint8_t *resp) {
(void)memcpy(resp, (uint8_t *)PROVISION_CHUNK_ADDRESS, PROVISION_CHUNK_LEN);
Expand Down
3 changes: 1 addition & 2 deletions board/safety/safety_mazda.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ static void mazda_rx_hook(const CANPacket_t *to_push) {

static bool mazda_tx_hook(const CANPacket_t *to_send) {
bool tx = true;
int addr = GET_ADDR(to_send);
int bus = GET_BUS(to_send);

// Check if msg is sent on the main BUS
if (bus == MAZDA_MAIN) {
int addr = GET_ADDR(to_send);

// steer cmd checks
if (addr == MAZDA_LKAS) {
Expand Down
5 changes: 2 additions & 3 deletions tests/misra/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ fi

cd $CPPCHECK_DIR

VERS="2.13.4"
git fetch --all --tags
VERS="2.14.1"
git fetch --all --tags --force
git checkout $VERS
git cherry-pick -n f6b538e855f0bacea33c4074664628024ef39dc6 b11b42087ff29569bc3740f5aa07eb6616ea4f63

#make clean
make MATCHCOMPILTER=yes CXXFLAGS="-O2" -j8
Loading