safety: include guards instead of #pragma once (MISRA 1.2) (#3976)

This commit is contained in:
Adeeb Shihadeh
2026-11-28 12:08:31 -06:00
committed by firestar5683
parent a4ccf7cd15
commit 0840288979
30 changed files with 120 additions and 30 deletions
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_DECLARATIONS_H
#define SAFETY_DECLARATIONS_H
#include <stdint.h>
#include <stdbool.h>
@@ -414,3 +415,5 @@ extern const safety_hooks leapmotor_hooks;
extern const safety_hooks volvo_cma_hooks;
extern const safety_hooks volvo_c1_hooks;
extern const safety_hooks volvo_dispatch_hooks;
#endif // SAFETY_DECLARATIONS_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_HELPERS_H
#define SAFETY_HELPERS_H
#include "opendbc/safety/declarations.h"
@@ -102,3 +103,5 @@ static float safety_interpolate(struct lookup_t xy, float x) {
}
return ret;
}
#endif // SAFETY_HELPERS_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_IGNITION_H
#define SAFETY_IGNITION_H
#include <stdbool.h>
#include <stdint.h>
@@ -118,3 +119,5 @@ void ignition_can_hook(const CANPacket_t *msg) {
prev_counter_vw_meb = counter;
}
}
#endif // SAFETY_IGNITION_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_BODY_H
#define SAFETY_MODES_BODY_H
#include "opendbc/safety/declarations.h"
@@ -68,3 +69,5 @@ const safety_hooks body_hooks = {
.get_checksum = body_get_checksum,
.compute_checksum = body_compute_checksum,
};
#endif // SAFETY_MODES_BODY_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_BYD_H
#define SAFETY_MODES_BYD_H
#include "opendbc/safety/declarations.h"
@@ -117,3 +118,5 @@ const safety_hooks byd_hooks = {
.get_checksum = byd_get_checksum,
.compute_checksum = byd_compute_checksum,
};
#endif // SAFETY_MODES_BYD_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_CHRYSLER_H
#define SAFETY_MODES_CHRYSLER_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/chrysler_common.h"
@@ -290,3 +291,5 @@ const safety_hooks chrysler_hooks = {
.get_checksum = chrysler_get_checksum,
.compute_checksum = chrysler_compute_checksum,
};
#endif // SAFETY_MODES_CHRYSLER_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_CHRYSLER_COMMON_H
#define SAFETY_MODES_CHRYSLER_COMMON_H
static uint32_t chrysler_get_checksum(const CANPacket_t *msg) {
int checksum_byte = GET_LEN(msg) - 1U;
@@ -13,3 +14,5 @@ static uint32_t chrysler_compute_checksum(const CANPacket_t *msg) {
}
return (uint8_t)(~checksum);
}
#endif // SAFETY_MODES_CHRYSLER_COMMON_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_DEFAULTS_H
#define SAFETY_MODES_DEFAULTS_H
#include "opendbc/safety/declarations.h"
@@ -48,3 +49,5 @@ const safety_hooks alloutput_hooks = {
.rx = default_rx_hook,
.tx = alloutput_tx_hook,
};
#endif // SAFETY_MODES_DEFAULTS_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_ELM327_H
#define SAFETY_MODES_ELM327_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/defaults.h"
@@ -39,3 +40,5 @@ const safety_hooks elm327_hooks = {
.rx = default_rx_hook,
.tx = elm327_tx_hook,
};
#endif // SAFETY_MODES_ELM327_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_FORD_H
#define SAFETY_MODES_FORD_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/ford_param.h"
@@ -632,3 +633,5 @@ const safety_hooks ford_hooks = {
.compute_checksum = ford_compute_checksum,
.get_quality_flag_valid = ford_get_quality_flag_valid,
};
#endif // SAFETY_MODES_FORD_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_GM_H
#define SAFETY_MODES_GM_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/can_tx.h"
@@ -1924,3 +1925,5 @@ const safety_hooks gm_hooks = {
.tx = gm_bolt_cc_tx,
.fwd = gm_bolt_cc_fwd,
};
#endif // SAFETY_MODES_GM_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_HONDA_H
#define SAFETY_MODES_HONDA_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/honda_interceptor.h"
@@ -689,3 +690,5 @@ const safety_hooks honda_bosch_hooks = {
.get_checksum = honda_get_checksum,
.compute_checksum = honda_compute_checksum,
};
#endif // SAFETY_MODES_HONDA_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_HYUNDAI_H
#define SAFETY_MODES_HYUNDAI_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/hyundai_common.h"
@@ -1167,3 +1168,5 @@ const safety_hooks hyundai_legacy_hooks = {
.get_checksum = hyundai_get_checksum,
.compute_checksum = hyundai_compute_checksum,
};
#endif // SAFETY_MODES_HYUNDAI_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_HYUNDAI_CANFD_H
#define SAFETY_MODES_HYUNDAI_CANFD_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/hyundai_common.h"
@@ -2398,3 +2399,5 @@ const safety_hooks hyundai_canfd_hooks = {
.get_checksum = hyundai_canfd_get_checksum,
.compute_checksum = hyundai_common_canfd_compute_checksum,
};
#endif // SAFETY_MODES_HYUNDAI_CANFD_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_HYUNDAI_COMMON_H
#define SAFETY_MODES_HYUNDAI_COMMON_H
#include "opendbc/safety/declarations.h"
@@ -201,3 +202,5 @@ uint32_t hyundai_common_canfd_compute_checksum(const CANPacket_t *msg) {
return crc;
}
#endif // SAFETY_MODES_HYUNDAI_COMMON_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_MAZDA_H
#define SAFETY_MODES_MAZDA_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/mazda_stock_aol.h"
@@ -128,3 +129,5 @@ const safety_hooks mazda_hooks = {
.optional_rx = mazda_aol_optional_rx,
.fwd = mazda_aol_fwd,
};
#endif // SAFETY_MODES_MAZDA_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_MG_H
#define SAFETY_MODES_MG_H
#include "opendbc/safety/declarations.h"
@@ -146,3 +147,5 @@ const safety_hooks mg_hooks = {
.compute_checksum = mg_compute_checksum,
.get_counter = mg_get_counter,
};
#endif // SAFETY_MODES_MG_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_NISSAN_H
#define SAFETY_MODES_NISSAN_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/nissan_aol.h"
@@ -171,3 +172,5 @@ const safety_hooks nissan_hooks = {
.tx = nissan_tx_hook,
.optional_rx = nissan_aol_observe,
};
#endif // SAFETY_MODES_NISSAN_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_PSA_H
#define SAFETY_MODES_PSA_H
#include "opendbc/safety/declarations.h"
@@ -129,3 +130,5 @@ const safety_hooks psa_hooks = {
.get_checksum = psa_get_checksum,
.compute_checksum = psa_compute_checksum,
};
#endif // SAFETY_MODES_PSA_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_RIVIAN_H
#define SAFETY_MODES_RIVIAN_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/rivian_stock_aol.h"
@@ -226,3 +227,5 @@ const safety_hooks rivian_hooks = {
.compute_checksum = rivian_compute_checksum,
.get_quality_flag_valid = rivian_get_quality_flag_valid,
};
#endif // SAFETY_MODES_RIVIAN_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_SUBARU_H
#define SAFETY_MODES_SUBARU_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/subaru_stock_aol.h"
@@ -524,3 +525,5 @@ const safety_hooks subaru_hooks = {
.get_checksum = subaru_get_checksum,
.compute_checksum = subaru_compute_checksum,
};
#endif // SAFETY_MODES_SUBARU_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_SUBARU_PREGLOBAL_H
#define SAFETY_MODES_SUBARU_PREGLOBAL_H
#include "opendbc/safety/declarations.h"
@@ -125,3 +126,5 @@ const safety_hooks subaru_preglobal_hooks = {
.tx = subaru_preglobal_tx_hook,
.get_counter = subaru_preglobal_counter,
};
#endif // SAFETY_MODES_SUBARU_PREGLOBAL_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_TESLA_H
#define SAFETY_MODES_TESLA_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/tesla_screen_aol.h"
@@ -391,3 +392,5 @@ const safety_hooks tesla_hooks = {
.compute_checksum = tesla_compute_checksum,
.get_quality_flag_valid = tesla_get_quality_flag_valid,
};
#endif // SAFETY_MODES_TESLA_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_TOYOTA_H
#define SAFETY_MODES_TOYOTA_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/toyota_aol.h"
@@ -901,3 +902,5 @@ const safety_hooks toyota_hooks = {
.compute_checksum = toyota_compute_checksum,
.get_quality_flag_valid = toyota_get_quality_flag_valid,
};
#endif // SAFETY_MODES_TOYOTA_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_VOLKSWAGEN_COMMON_H
#define SAFETY_MODES_VOLKSWAGEN_COMMON_H
extern const uint16_t FLAG_VOLKSWAGEN_LONG_CONTROL;
const uint16_t FLAG_VOLKSWAGEN_LONG_CONTROL = 1;
@@ -130,3 +131,5 @@ static int volkswagen_mlb_mqb_steering_control_torque(const CANPacket_t *msg) {
}
return desired_torque;
}
#endif // SAFETY_MODES_VOLKSWAGEN_COMMON_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_VOLKSWAGEN_MEB_H
#define SAFETY_MODES_VOLKSWAGEN_MEB_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/volkswagen_common.h"
@@ -333,3 +334,5 @@ const safety_hooks volkswagen_meb_hooks = {
.get_checksum = volkswagen_mxb_get_checksum,
.compute_checksum = volkswagen_meb_alt_crc_compute,
};
#endif // SAFETY_MODES_VOLKSWAGEN_MEB_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_VOLKSWAGEN_MLB_H
#define SAFETY_MODES_VOLKSWAGEN_MLB_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/volkswagen_common.h"
@@ -122,3 +123,5 @@ const safety_hooks volkswagen_mlb_hooks = {
.get_checksum = volkswagen_mxb_get_checksum,
.compute_checksum = volkswagen_mxb_compute_crc,
};
#endif // SAFETY_MODES_VOLKSWAGEN_MLB_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_VOLKSWAGEN_MQB_H
#define SAFETY_MODES_VOLKSWAGEN_MQB_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/volkswagen_common.h"
@@ -257,3 +258,5 @@ const safety_hooks volkswagen_mqb_hooks = {
.get_checksum = volkswagen_mxb_get_checksum,
.compute_checksum = volkswagen_mxb_compute_crc,
};
#endif // SAFETY_MODES_VOLKSWAGEN_MQB_H
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_MODES_VOLKSWAGEN_PQ_H
#define SAFETY_MODES_VOLKSWAGEN_PQ_H
#include "opendbc/safety/declarations.h"
#include "opendbc/safety/modes/volkswagen_common.h"
@@ -257,3 +258,5 @@ const safety_hooks volkswagen_pq_hooks = {
.get_checksum = volkswagen_pq_get_checksum,
.compute_checksum = volkswagen_pq_compute_checksum,
};
#endif // SAFETY_MODES_VOLKSWAGEN_PQ_H
+4 -1
View File
@@ -1,4 +1,5 @@
#pragma once
#ifndef SAFETY_H
#define SAFETY_H
#include "opendbc/safety/helpers.h"
#include "opendbc/safety/lateral.h"
@@ -654,3 +655,5 @@ void speed_mismatch_check(const float speed_2) {
controls_allowed = false;
}
}
#endif // SAFETY_H