From c0bdcc58df7cea5f82bc2df04911caee3e38372c Mon Sep 17 00:00:00 2001 From: Aubrey Wahl <10409668+aubsw@users.noreply.github.com> Date: Wed, 14 May 2025 17:30:49 -0400 Subject: [PATCH] enable cpplint (#2238) * enable cpplint * fix misra * newline --------- Co-authored-by: Adeeb Shihadeh --- .pre-commit-config.yaml | 19 +++++++++---------- SConstruct | 1 + opendbc/can/common.cc | 3 +++ opendbc/can/dbc.cc | 2 ++ opendbc/can/packer.cc | 2 ++ opendbc/can/parser.cc | 3 +++ opendbc/safety/board/can.h | 2 +- opendbc/safety/board/drivers/can_common.h | 2 +- opendbc/safety/board/fake_stm.h | 2 +- opendbc/safety/board/faults.h | 2 +- opendbc/safety/board/utils.h | 10 +++++----- opendbc/safety/main.c | 2 +- opendbc/safety/safety.h | 4 ++-- opendbc/safety/safety/safety_body.h | 2 +- opendbc/safety/safety/safety_chrysler.h | 2 +- opendbc/safety/safety/safety_defaults.h | 6 +++--- opendbc/safety/safety/safety_elm327.h | 4 ++-- opendbc/safety/safety/safety_ford.h | 2 +- opendbc/safety/safety/safety_gm.h | 2 +- opendbc/safety/safety/safety_honda.h | 2 +- opendbc/safety/safety/safety_hyundai.h | 4 ++-- opendbc/safety/safety/safety_hyundai_canfd.h | 4 ++-- opendbc/safety/safety/safety_hyundai_common.h | 2 +- opendbc/safety/safety/safety_mazda.h | 2 +- opendbc/safety/safety/safety_nissan.h | 2 +- opendbc/safety/safety/safety_rivian.h | 2 +- opendbc/safety/safety/safety_subaru.h | 2 +- .../safety/safety/safety_subaru_preglobal.h | 2 +- opendbc/safety/safety/safety_tesla.h | 2 +- opendbc/safety/safety/safety_toyota.h | 2 +- .../safety/safety/safety_volkswagen_common.h | 10 +++++----- opendbc/safety/safety/safety_volkswagen_mqb.h | 4 ++-- opendbc/safety/safety/safety_volkswagen_pq.h | 4 ++-- opendbc/safety/safety_declarations.h | 2 +- opendbc/safety/tests/libsafety/SConscript | 2 +- opendbc/safety/tests/libsafety/safety.c | 12 ++++++------ .../safety/tests/libsafety/safety_helpers.h | 2 ++ opendbc/safety/tests/misra/test_misra.sh | 7 +++++-- 38 files changed, 78 insertions(+), 63 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9ba57906..5eae1cde 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,13 +29,12 @@ repos: hooks: - id: cython-lint - id: double-quote-cython-strings -# TODO: enable this and fix all the errors -#- repo: https://github.com/cpplint/cpplint -# rev: 2.0.2 -# hooks: -# - id: cpplint -# args: -# - --quiet -# - --counting=detailed -# - --linelength=240 -# - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces +- repo: https://github.com/cpplint/cpplint + rev: 2.0.2 + hooks: + - id: cpplint + args: + - --quiet + - --counting=detailed + - --linelength=240 + - --filter=-build,-legal,-readability,-runtime,-whitespace,+build/include_subdir,+build/forward_decl,+build/include_what_you_use,+build/deprecated,+whitespace/comma,+whitespace/line_length,+whitespace/empty_if_body,+whitespace/empty_loop_body,+whitespace/empty_conditional_body,+whitespace/forcolon,+whitespace/parens,+whitespace/semicolon,+whitespace/tab,+readability/braces diff --git a/SConstruct b/SConstruct index 352e07a5..c588c739 100644 --- a/SConstruct +++ b/SConstruct @@ -11,6 +11,7 @@ if platform.system() == "Darwin": python_path = sysconfig.get_paths()['include'] cpppath = [ '#', + '#opendbc', '/usr/lib/include', python_path ] diff --git a/opendbc/can/common.cc b/opendbc/can/common.cc index 24494161..7b5a5a8b 100644 --- a/opendbc/can/common.cc +++ b/opendbc/can/common.cc @@ -1,5 +1,8 @@ #include +#include +#include #include +#include #include "opendbc/can/common.h" diff --git a/opendbc/can/dbc.cc b/opendbc/can/dbc.cc index 51792827..e5ee6f2f 100644 --- a/opendbc/can/dbc.cc +++ b/opendbc/can/dbc.cc @@ -2,9 +2,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include diff --git a/opendbc/can/packer.cc b/opendbc/can/packer.cc index 807d9722..e2264e32 100644 --- a/opendbc/can/packer.cc +++ b/opendbc/can/packer.cc @@ -3,7 +3,9 @@ #include #include #include +#include #include +#include #include "opendbc/can/common.h" diff --git a/opendbc/can/parser.cc b/opendbc/can/parser.cc index 1607b092..dedb584b 100644 --- a/opendbc/can/parser.cc +++ b/opendbc/can/parser.cc @@ -2,8 +2,11 @@ #include #include #include +#include #include #include +#include +#include #include "opendbc/can/common.h" diff --git a/opendbc/safety/board/can.h b/opendbc/safety/board/can.h index b2fe0ca3..ee87a304 100644 --- a/opendbc/safety/board/can.h +++ b/opendbc/safety/board/can.h @@ -1,4 +1,4 @@ #pragma once -#include "can_declarations.h" +#include "safety/board/can_declarations.h" static const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; diff --git a/opendbc/safety/board/drivers/can_common.h b/opendbc/safety/board/drivers/can_common.h index 306f0c07..dce34115 100644 --- a/opendbc/safety/board/drivers/can_common.h +++ b/opendbc/safety/board/drivers/can_common.h @@ -1,5 +1,5 @@ #pragma once -#include "can_common_declarations.h" +#include "safety/board/drivers/can_common_declarations.h" uint8_t calculate_checksum(const uint8_t *dat, uint32_t len) { uint8_t checksum = 0U; diff --git a/opendbc/safety/board/fake_stm.h b/opendbc/safety/board/fake_stm.h index 8f94e79e..c1af9a6a 100644 --- a/opendbc/safety/board/fake_stm.h +++ b/opendbc/safety/board/fake_stm.h @@ -3,7 +3,7 @@ #include #include -#include "utils.h" +#include "safety/board/utils.h" #define ALLOW_DEBUG #define PANDA diff --git a/opendbc/safety/board/faults.h b/opendbc/safety/board/faults.h index 0fc9d2c5..3288a635 100644 --- a/opendbc/safety/board/faults.h +++ b/opendbc/safety/board/faults.h @@ -1,4 +1,4 @@ -#include "faults_declarations.h" +#include "safety/board/faults_declarations.h" uint8_t fault_status = FAULT_STATUS_NONE; uint32_t faults = 0U; diff --git a/opendbc/safety/board/utils.h b/opendbc/safety/board/utils.h index 20b24621..db011ddb 100644 --- a/opendbc/safety/board/utils.h +++ b/opendbc/safety/board/utils.h @@ -1,14 +1,14 @@ // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension #define MIN(a, b) ({ \ - __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ + __typeof__(a) _a = (a); \ + __typeof__(b) _b = (b); \ (_a < _b) ? _a : _b; \ }) // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension #define MAX(a, b) ({ \ - __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ + __typeof__(a) _a = (a); \ + __typeof__(b) _b = (b); \ (_a > _b) ? _a : _b; \ }) @@ -22,7 +22,7 @@ // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension #define ABS(a) ({ \ - __typeof__ (a) _a = (a); \ + __typeof__(a) _a = (a); \ (_a > 0) ? _a : (-_a); \ }) diff --git a/opendbc/safety/main.c b/opendbc/safety/main.c index 3c873f84..bb060483 100644 --- a/opendbc/safety/main.c +++ b/opendbc/safety/main.c @@ -1,4 +1,4 @@ -#include "safety.h" +#include "safety/safety.h" // this file is checked by cppcheck diff --git a/opendbc/safety/safety.h b/opendbc/safety/safety.h index 547a7283..3a82e3b0 100644 --- a/opendbc/safety/safety.h +++ b/opendbc/safety/safety.h @@ -1,7 +1,7 @@ #pragma once -#include "safety_declarations.h" -#include "can.h" +#include "safety/safety_declarations.h" +#include "safety/board/can.h" // include the safety policies. #include "safety/safety_defaults.h" diff --git a/opendbc/safety/safety/safety_body.h b/opendbc/safety/safety/safety_body.h index 6536178a..046a66a3 100644 --- a/opendbc/safety/safety/safety_body.h +++ b/opendbc/safety/safety/safety_body.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" static void body_rx_hook(const CANPacket_t *to_push) { // body is never at standstill diff --git a/opendbc/safety/safety/safety_chrysler.h b/opendbc/safety/safety/safety_chrysler.h index 628bf6ed..3f9cdbd1 100644 --- a/opendbc/safety/safety/safety_chrysler.h +++ b/opendbc/safety/safety/safety_chrysler.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" typedef struct { const int EPS_2; diff --git a/opendbc/safety/safety/safety_defaults.h b/opendbc/safety/safety/safety_defaults.h index 8c2a01de..9b654c8b 100644 --- a/opendbc/safety/safety/safety_defaults.h +++ b/opendbc/safety/safety/safety_defaults.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // GCOV_EXCL_START // Unreachable by design (doesn't define any rx msgs) @@ -13,7 +13,7 @@ void default_rx_hook(const CANPacket_t *to_push) { static safety_config nooutput_init(uint16_t param) { UNUSED(param); - return (safety_config){NULL, 0, NULL, 0, true}; + return (safety_config){NULL, 0, NULL, 0, true}; // NOLINT(readability/braces) } // GCOV_EXCL_START @@ -36,7 +36,7 @@ static safety_config alloutput_init(uint16_t param) { const uint16_t ALLOUTPUT_PARAM_PASSTHROUGH = 1; controls_allowed = true; bool alloutput_passthrough = GET_FLAG(param, ALLOUTPUT_PARAM_PASSTHROUGH); - return (safety_config){NULL, 0, NULL, 0, !alloutput_passthrough}; + return (safety_config){NULL, 0, NULL, 0, !alloutput_passthrough}; // NOLINT(readability/braces) } static bool alloutput_tx_hook(const CANPacket_t *to_send) { diff --git a/opendbc/safety/safety/safety_elm327.h b/opendbc/safety/safety/safety_elm327.h index 9a7277fc..c2adc628 100644 --- a/opendbc/safety/safety/safety_elm327.h +++ b/opendbc/safety/safety/safety_elm327.h @@ -1,7 +1,7 @@ #pragma once -#include "safety_declarations.h" -#include "safety_defaults.h" +#include "safety/safety_declarations.h" +#include "safety/safety_defaults.h" static bool elm327_tx_hook(const CANPacket_t *to_send) { const int GM_CAMERA_DIAG_ADDR = 0x24B; diff --git a/opendbc/safety/safety/safety_ford.h b/opendbc/safety/safety/safety_ford.h index c45bc9a6..4a02aca5 100644 --- a/opendbc/safety/safety/safety_ford.h +++ b/opendbc/safety/safety/safety_ford.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // Safety-relevant CAN messages for Ford vehicles. #define FORD_EngBrakeData 0x165 // RX from PCM, for driver brake pedal and cruise state diff --git a/opendbc/safety/safety/safety_gm.h b/opendbc/safety/safety/safety_gm.h index 4c4f19d1..fe592f85 100644 --- a/opendbc/safety/safety/safety_gm.h +++ b/opendbc/safety/safety/safety_gm.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // TODO: do checksum and counter checks. Add correct timestep, 0.1s for now. #define GM_COMMON_RX_CHECKS \ diff --git a/opendbc/safety/safety/safety_honda.h b/opendbc/safety/safety/safety_honda.h index ffeaf89a..678609f0 100644 --- a/opendbc/safety/safety/safety_honda.h +++ b/opendbc/safety/safety/safety_honda.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // All common address checks except SCM_BUTTONS which isn't on one Nidec safety configuration #define HONDA_COMMON_NO_SCM_FEEDBACK_RX_CHECKS(pt_bus) \ diff --git a/opendbc/safety/safety/safety_hyundai.h b/opendbc/safety/safety/safety_hyundai.h index a7a8423b..3f6f09d4 100644 --- a/opendbc/safety/safety/safety_hyundai.h +++ b/opendbc/safety/safety/safety_hyundai.h @@ -1,7 +1,7 @@ #pragma once -#include "safety_declarations.h" -#include "safety_hyundai_common.h" +#include "safety/safety_declarations.h" +#include "safety/safety_hyundai_common.h" #define HYUNDAI_LIMITS(steer, rate_up, rate_down) { \ .max_torque = (steer), \ diff --git a/opendbc/safety/safety/safety_hyundai_canfd.h b/opendbc/safety/safety/safety_hyundai_canfd.h index c5a1a358..bbab8b6f 100644 --- a/opendbc/safety/safety/safety_hyundai_canfd.h +++ b/opendbc/safety/safety/safety_hyundai_canfd.h @@ -1,7 +1,7 @@ #pragma once -#include "safety_declarations.h" -#include "safety_hyundai_common.h" +#include "safety/safety_declarations.h" +#include "safety/safety_hyundai_common.h" #define HYUNDAI_CANFD_CRUISE_BUTTON_TX_MSGS(bus) \ {0x1CF, bus, 8, .check_relay = false}, /* CRUISE_BUTTON */ \ diff --git a/opendbc/safety/safety/safety_hyundai_common.h b/opendbc/safety/safety/safety_hyundai_common.h index afee9744..8d797f31 100644 --- a/opendbc/safety/safety/safety_hyundai_common.h +++ b/opendbc/safety/safety/safety_hyundai_common.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" extern uint16_t hyundai_canfd_crc_lut[256]; uint16_t hyundai_canfd_crc_lut[256]; diff --git a/opendbc/safety/safety/safety_mazda.h b/opendbc/safety/safety/safety_mazda.h index 87088353..acee5b1c 100644 --- a/opendbc/safety/safety/safety_mazda.h +++ b/opendbc/safety/safety/safety_mazda.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // CAN msgs we care about #define MAZDA_LKAS 0x243 diff --git a/opendbc/safety/safety/safety_nissan.h b/opendbc/safety/safety/safety_nissan.h index dd2ad677..ce4c25f5 100644 --- a/opendbc/safety/safety/safety_nissan.h +++ b/opendbc/safety/safety/safety_nissan.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" static bool nissan_alt_eps = false; diff --git a/opendbc/safety/safety/safety_rivian.h b/opendbc/safety/safety/safety_rivian.h index 1f6d8b72..4b028ca1 100644 --- a/opendbc/safety/safety/safety_rivian.h +++ b/opendbc/safety/safety/safety_rivian.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" #define RIVIAN_MAX_SPEED_DELTA 2.0 // m/s diff --git a/opendbc/safety/safety/safety_subaru.h b/opendbc/safety/safety/safety_subaru.h index 17da4067..b394a308 100644 --- a/opendbc/safety/safety/safety_subaru.h +++ b/opendbc/safety/safety/safety_subaru.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" #define SUBARU_STEERING_LIMITS_GENERATOR(steer_max, rate_up, rate_down) \ { \ diff --git a/opendbc/safety/safety/safety_subaru_preglobal.h b/opendbc/safety/safety/safety_subaru_preglobal.h index f477d8cf..753d7bb6 100644 --- a/opendbc/safety/safety/safety_subaru_preglobal.h +++ b/opendbc/safety/safety/safety_subaru_preglobal.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // Preglobal platform // 0x161 is ES_CruiseThrottle diff --git a/opendbc/safety/safety/safety_tesla.h b/opendbc/safety/safety/safety_tesla.h index 56a07aef..c6a3832c 100644 --- a/opendbc/safety/safety/safety_tesla.h +++ b/opendbc/safety/safety/safety_tesla.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" #define TESLA_MAX_SPEED_DELTA 2.0 // m/s diff --git a/opendbc/safety/safety/safety_toyota.h b/opendbc/safety/safety/safety_toyota.h index d97d6178..58596d47 100644 --- a/opendbc/safety/safety/safety_toyota.h +++ b/opendbc/safety/safety/safety_toyota.h @@ -1,6 +1,6 @@ #pragma once -#include "safety_declarations.h" +#include "safety/safety_declarations.h" // Stock longitudinal #define TOYOTA_BASE_TX_MSGS \ diff --git a/opendbc/safety/safety/safety_volkswagen_common.h b/opendbc/safety/safety/safety_volkswagen_common.h index 1285bb88..72525dcc 100644 --- a/opendbc/safety/safety/safety_volkswagen_common.h +++ b/opendbc/safety/safety/safety_volkswagen_common.h @@ -53,15 +53,15 @@ static uint32_t volkswagen_mqb_meb_compute_crc(const CANPacket_t *to_push) { uint8_t counter = volkswagen_mqb_meb_get_counter(to_push); if (addr == MSG_LH_EPS_03) { - crc ^= (uint8_t[]){0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5,0xF5}[counter]; + crc ^= (uint8_t[]){0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5}[counter]; } else if (addr == MSG_ESP_05) { - crc ^= (uint8_t[]){0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07}[counter]; + crc ^= (uint8_t[]){0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07}[counter]; } else if (addr == MSG_TSK_06) { - crc ^= (uint8_t[]){0xC4,0xE2,0x4F,0xE4,0xF8,0x2F,0x56,0x81,0x9F,0xE5,0x83,0x44,0x05,0x3F,0x97,0xDF}[counter]; + crc ^= (uint8_t[]){0xC4, 0xE2, 0x4F, 0xE4, 0xF8, 0x2F, 0x56, 0x81, 0x9F, 0xE5, 0x83, 0x44, 0x05, 0x3F, 0x97, 0xDF}[counter]; } else if (addr == MSG_MOTOR_20) { - crc ^= (uint8_t[]){0xE9,0x65,0xAE,0x6B,0x7B,0x35,0xE5,0x5F,0x4E,0xC7,0x86,0xA2,0xBB,0xDD,0xEB,0xB4}[counter]; + crc ^= (uint8_t[]){0xE9, 0x65, 0xAE, 0x6B, 0x7B, 0x35, 0xE5, 0x5F, 0x4E, 0xC7, 0x86, 0xA2, 0xBB, 0xDD, 0xEB, 0xB4}[counter]; } else if (addr == MSG_GRA_ACC_01) { - crc ^= (uint8_t[]){0x6A,0x38,0xB4,0x27,0x22,0xEF,0xE1,0xBB,0xF8,0x80,0x84,0x49,0xC7,0x9E,0x1E,0x2B}[counter]; + crc ^= (uint8_t[]){0x6A, 0x38, 0xB4, 0x27, 0x22, 0xEF, 0xE1, 0xBB, 0xF8, 0x80, 0x84, 0x49, 0xC7, 0x9E, 0x1E, 0x2B}[counter]; } else { // Undefined CAN message, CRC check expected to fail } diff --git a/opendbc/safety/safety/safety_volkswagen_mqb.h b/opendbc/safety/safety/safety_volkswagen_mqb.h index a87f9b3c..e96974d9 100644 --- a/opendbc/safety/safety/safety_volkswagen_mqb.h +++ b/opendbc/safety/safety/safety_volkswagen_mqb.h @@ -1,7 +1,7 @@ #pragma once -#include "safety_declarations.h" -#include "safety_volkswagen_common.h" +#include "safety/safety_declarations.h" +#include "safety/safety_volkswagen_common.h" static bool volkswagen_mqb_brake_pedal_switch = false; static bool volkswagen_mqb_brake_pressure_detected = false; diff --git a/opendbc/safety/safety/safety_volkswagen_pq.h b/opendbc/safety/safety/safety_volkswagen_pq.h index 193a1254..418cdafb 100644 --- a/opendbc/safety/safety/safety_volkswagen_pq.h +++ b/opendbc/safety/safety/safety_volkswagen_pq.h @@ -1,7 +1,7 @@ #pragma once -#include "safety_declarations.h" -#include "safety_volkswagen_common.h" +#include "safety/safety_declarations.h" +#include "safety/safety_volkswagen_common.h" #define MSG_LENKHILFE_3 0x0D0 // RX from EPS, for steering angle and driver steering torque #define MSG_HCA_1 0x0D2 // TX by OP, Heading Control Assist steering torque diff --git a/opendbc/safety/safety_declarations.h b/opendbc/safety/safety_declarations.h index 8ebf0e09..995b9bca 100644 --- a/opendbc/safety/safety_declarations.h +++ b/opendbc/safety/safety_declarations.h @@ -52,7 +52,7 @@ (config).tx_msgs = (tx); \ (config).tx_msgs_len = sizeof((tx)) / sizeof((tx)[0]); \ (config).disable_forwarding = false; \ - } while(0); + } while (0); #define UPDATE_VEHICLE_SPEED(val_ms) (update_sample(&vehicle_speed, ROUND((val_ms) * VEHICLE_SPEED_FACTOR))) diff --git a/opendbc/safety/tests/libsafety/SConscript b/opendbc/safety/tests/libsafety/SConscript index 5d66b3eb..cd6f7f20 100644 --- a/opendbc/safety/tests/libsafety/SConscript +++ b/opendbc/safety/tests/libsafety/SConscript @@ -23,7 +23,7 @@ env = Environment( '-Wfatal-errors', '-Wno-pointer-to-int-cast', ], - CPPPATH=[".", "../../board/", "../../"], + CPPPATH=[".", "../../board/", "../../", "../../../"], ) if system == "Darwin": env.PrependENVPath('PATH', '/opt/homebrew/bin') diff --git a/opendbc/safety/tests/libsafety/safety.c b/opendbc/safety/tests/libsafety/safety.c index bdb63596..a8aa6043 100644 --- a/opendbc/safety/tests/libsafety/safety.c +++ b/opendbc/safety/tests/libsafety/safety.c @@ -1,13 +1,13 @@ #include -#include "fake_stm.h" -#include "can.h" +#include "safety/board/fake_stm.h" +#include "safety/board/can.h" //int safety_tx_hook(CANPacket_t *to_send) { return 1; } -#include "faults.h" -#include "safety.h" -#include "drivers/can_common.h" +#include "safety/board/faults.h" +#include "safety/safety.h" +#include "safety/board/drivers/can_common.h" // libsafety stuff -#include "safety_helpers.h" +#include "safety/tests/libsafety/safety_helpers.h" diff --git a/opendbc/safety/tests/libsafety/safety_helpers.h b/opendbc/safety/tests/libsafety/safety_helpers.h index e9e4411f..1176e8ca 100644 --- a/opendbc/safety/tests/libsafety/safety_helpers.h +++ b/opendbc/safety/tests/libsafety/safety_helpers.h @@ -1,3 +1,5 @@ +#include + void safety_tick_current_safety_config() { safety_tick(¤t_safety_config); } diff --git a/opendbc/safety/tests/misra/test_misra.sh b/opendbc/safety/tests/misra/test_misra.sh index 0ff97d71..7310036c 100755 --- a/opendbc/safety/tests/misra/test_misra.sh +++ b/opendbc/safety/tests/misra/test_misra.sh @@ -45,8 +45,11 @@ cppcheck() { echo -e "\n\n\n\n\nTEST variant options:" >> $CHECKLIST echo -e ""${@//$BASEDIR/}"\n\n" >> $CHECKLIST # (absolute path removed) - $CPPCHECK_DIR/cppcheck --inline-suppr -I $BASEDIR/opendbc/safety/ \ - -I $BASEDIR/opendbc/safety/safety/ -I $BASEDIR/opendbc/safety/board/ \ + $CPPCHECK_DIR/cppcheck --inline-suppr \ + -I $BASEDIR/opendbc/ \ + -I $BASEDIR/opendbc/safety/ \ + -I $BASEDIR/opendbc/safety/safety/ \ + -I $BASEDIR/opendbc/safety/board/ \ -I "$(arm-none-eabi-gcc -print-file-name=include)" \ --suppressions-list=$DIR/suppressions.txt --suppress=*:*inc/* \ --suppress=*:*include/* --error-exitcode=2 --check-level=exhaustive --safety \