RTE RBC 2oo2 Generic Application 0.1.0 build 308eda7
IL/CTC route and train logic for the RBC_GP reference RBC
Loading...
Searching...
No Matches
MISRA C:2012 Compliance Report — RTE RBC 2oo2 Generic Application (RBC_GA)

Guideline: MISRA C:2012 (with Amendment 1). Target: EN 50128 SIL 4 oriented for the vital AB/ code (src/AB/); the C/ files (gateway_c_il_handler.c, gateway_c_logctl.c, gateway_c_ctc_handler.c, main_c_il.c, main_c_ctc.c) are role C, non-vital (ADR-001 section 4), included below for completeness but not to that target.

This is a cppcheck MISRA-addon screening pass, not a full compliance verdict** — see RBC_GP's own docs/MISRA_COMPLIANCE_REPORT.dox for the full explanation of why (no licensed --rule-texts= available; this report's rule glosses are this report's own plain-language paraphrase, not the official wording) and its own Update 1 entry for the sibling stdio/stdlib deviation this project shares the same posture on. Tracked as a still-open, larger item in the root TODO.dox for a real, individually-reviewed compliance verdict.

Update log

Update 1 — 2026-09-22 — cppcheck --addon=misra screening pass (src/AB/ + src/C/)

RBC_GA has no standalone build of its own (compiled as part of RBC_GP's build, add_subdirectory() — see this project's own CLAUDE.md): ran cppcheck --addon=misra --enable=warning,style,performance,portability against RBC_GP's build/compile_commands.json, filtered to this project's own 11 source files (application/RBC_GA/src/), then filtered a second time on each finding's own reported file path to drop findings cppcheck attributes to a header this project #includes but does not own (mostly RBC_GP's and Platform_RTE's shared headers) — those belong to that header's own owning project's report.

192 MISRA-addon findings**:

Rule Count General topic (this report's own gloss, not official text)
15.5 91 Multiple return statements in one function
21.6 35 <stdio.h> use (same posture as RBC_GP's own Update 1 — not re-litigated here)
17.7 26 A function call's return value is not used/checked
... 40 17 further rules, single/low-digit counts each — full breakdown: misra_screening/rbc_ga_misra_rule_counts.txt

18 free-tier findings** (misra_screening/rbc_ga_cppcheck_free_findings.txt; warning/style/performance/portability — need no licensed text, every one a real finding, not a rule-number-only flag): mostly constParameterPointer and variableScope — cosmetic. The same while ((status = ...) == RTE_STATUS_OK) { ... } if ((status != RTE_STATUS_OK) && ...) redundant-first-clause idiom RBC_GP's own report flags in gateway_c_train_handler.c repeats identically in this project's gateway_c_il_handler.c (lines 166, 199) and gateway_c_ctc_handler.c (lines 134, 167) — a shared pattern across all three gateway handlers, both role C / non-vital, not a bug.

No code changed by this update.

Update 2 — 2026-10-04 — IL/CTC Gateways: RTE_STATUS_NOT_CONNECTED handled as OK (G4 item 6f-2)

Role C (non-vital): src/C/il/gateway_c_il_handler.c (broadcast_one(), send_to_relay(), send_to_sim()) and src/C/ctc/gateway_c_ctc_handler.c (send_to_relay(), send_to_sim()) handle RTE_STATUS_NOT_CONNECTED (Platform_RTE REQ-CHANSVC-001; the POSIX channel service now returns it where it returned OK before) exactly as OK: the relay sends take their OK branch, the sim sends and the log-level broadcast add it to their silent set. One more || / && operand per condition, fully parenthesised; no new branch, call or variable. Screened with cppcheck 2.21 --addon=misra --enable=warning,style,performance,portability --std=c99, include paths and defines from RBC_GP's build/compile_commands.json, against the same run on the HEAD version of each file, findings in that file only:

File Rule / id Before After Note
gateway_c_il_handler.c 10.4, 10.8, 13.4, 15.5, 15.7, 17.7, 21.6, 8.7 1, 1, 2, 5, 1, 5, 6, 5 unchanged pre-existing; no finding on the changed conditions (lines 29, 88, 119)
gateway_c_il_handler.c free-tier constParameterPointer, knownConditionTrueFalse, variableScope 3, 2, 1 unchanged pre-existing
gateway_c_ctc_handler.c 10.4, 10.8, 13.4, 15.5, 15.7, 17.7, 21.6, 8.7 1, 1, 2, 5, 1, 5, 6, 4 unchanged pre-existing; no finding on the changed conditions (lines 72, 103)
gateway_c_ctc_handler.c free-tier constParameterPointer, knownConditionTrueFalse, variableScope 3, 2, 1 unchanged pre-existing

Totals (rule findings): il 26 before, 26 after; ctc 25 before, 25 after; in each file the finding sequence is identical apart from line numbers.

Update 3 — 2026-10-04 — CTC latches set at confirm, not at build (root ISSUES.dox ISS-047)

Vital A/B code: src/AB/ctc/ab_ga_ctc.c and src/AB/main/ab_ga_dispatch.c. ab_ga_ctc_build_outputs() no longer calls ab_gp_train_session_set_ctc_connected_sent() / _set_ctc_ma_granted_sent(); it records the trains in two file-static bool arrays (g_connected_built[], g_ma_granted_built[], RTE_EXAMPLE_MAX_TRAINS entries, cleared at the start of every build), and ab_ga_ctc_confirm_outputs_sent() (now taking the session table) calls the two setters from that record. ab_ga_ctc_build_outputs()'s sessions parameter became pointer to const (it only reads now, Rule 8.13). ctc_output_confirm_trampoline() unpacks the session table from its registration context, as ctc_output_producer_trampoline() already does. No dynamic memory, no recursion, no new loop bound (every loop runs RTE_EXAMPLE_MAX_TRAINS times). Screened with cppcheck 2.21 --addon=misra --enable=warning,style,performance,portability --std=c99, include paths and defines from RBC_GP's build/compile_commands.json, against the same run on the HEAD version of each file, findings in that file only:

File Rule / id Before After Note
ab_ga_ctc.c 10.8, 15.5, 17.7, 21.6, 8.7, 8.9 1, 5, 1, 1, 4, 1 unchanged pre-existing
ab_ga_ctc.c free-tier constParameterPointer 1 1 pre-existing (db); the one the change would have added on sessions is fixed by the const
ab_ga_dispatch.c 11.5 (advisory) 2 3 new: const void *context converted to const ga_channel_ctx_t * in ctc_output_confirm_trampoline(), the same conversion as the two existing ones (on_route_context_changed(), ctc_output_producer_trampoline()); the callback signature ab_gp_ctc_output_confirm_fn (ga_interface.h) passes the registration context as const void *, and the pointer is the address of g_channel_ctx this module registered itself
ab_ga_dispatch.c 15.5, 8.7, 8.9 5, 1, 1 unchanged pre-existing

Totals (rule findings): ab_ga_ctc.c 13 before, 13 after; ab_ga_dispatch.c 9 before, 10 after (the advisory 11.5 above). No mandatory or required rule finding added.

Unit test: RBC_GP/tests/ctc/test_ab_ga_ctc_outputs.c (RBC_GA tests are hosted in RBC_GP), 8 cases including the negative ones (unconfirmed build, stale build record, NULL session table).

Deviations

None recorded beyond RBC_GP's own Update 1 (<stdio.h>/<stdlib.h>, Rules 21.6/21.8), which this project shares the same posture on — see that report.

Rules to watch as this report grows

Rule Where it will bite Plan
Full per-rule sweep, individually reviewed All of src/AB/, src/C/ Needs the cppcheck MISRA addon rule text or a licensed tool — tracked in root TODO.dox.