refactor: S10.12 pilot — Buffer group conformance + anonymous-enum policy#382
Conversation
…licy Resolves all warning-mode cppcheck-misra + clang-tidy findings against the Buffer cluster (NullBuffer, CircularBuffer, PosixMessageQueueBuffer plus the SolidSyslogBuffer base) and settles the tree-wide anonymous-enum named-constant policy that S10.07 left open. MISRA fixes — 9 sites, every one a real local fix (no blanket suppressions): - 4× rule 17.7 in SolidSyslogCircularBuffer.c memcpy calls — (void) cast - 1× rule 17.7 in SolidSyslogNullBuffer.c Sender_Send call — (void) cast - 1× rule 15.5 in CircularBuffer_RecordFitsAtTail — single-exit refactor - 2× rule 5.9 — bare `instance` static collided across TUs; renamed to NullBuffer_Instance and PosixMessageQueueBuffer_Instance per Tier 2 - 1× rule 8.9 — QUEUE_NAME_PREFIX moved to block scope inside _Create - 2× rule 21.15 (newly visible after fixing 17.7) — CircularBuffer's uint16_t↔uint8_t* memcpy header replaced with explicit little-endian byte read/write; no rule deviation needed Anonymous-enum policy (option C from S10.12 design discussion): - .clang-tidy gains EnumConstantIgnoredRegexp accepting SCREAMING_SNAKE, clearing all 101 anonymous-enum sites tree-wide without renaming code. Named (tagged) enum rule SolidSyslog<Class>_Constant stays tight. - docs/NAMING.md Macros section gains "Anonymous-enum named-constant idiom" subsection - D.010 (existing project-wide deviation for the cppcheck-misra 2.4 hit on this idiom) extended with the 2 buffer-file sites — same pattern, same rationale, count 6 → 8 Audit doc freeze: - docs/misra-conformance.md was the S10.05 audit working record. With the cross-cutting sweeps complete (S10.07–S10.11, S10.21) and the per-group phase opening, the audit is finished. Frozen header points readers at the two live sources of truth and flags the file for deletion at S10.20 Verified locally: - 1120 tests pass under debug, sanitize, clang-debug - 100% line + function coverage preserved on all 4 buffer source files - analyze-tidy and analyze-cppcheck (with cppcheck-misra) clean - analyze-format clean Closes #381 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR implements the first per-group MISRA conformance pass (S10.12) on the buffer cluster, resolving nine findings through targeted local fixes and establishing the tree-wide anonymous-enum naming policy. Changes include explicit little-endian byte handling, control-flow restructuring, TU-local static renames, a ChangesBuffer-group MISRA conformance + anonymous-enum policy
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
☀️ Quality Summary 🚦 build-linux-gcc: 100% successful (✔️ 1126 passed, 🙈 2 skipped) Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result. |
Purpose
First per-group conformance story in E10. Resolves all warning-mode findings raised by
analyze-tidyandanalyze-cppcheck(with the cppcheck-misra addon) against the Buffer cluster (NullBuffer, CircularBuffer, PosixMessageQueueBuffer, plus the SolidSyslogBuffer base), and settles the tree-wide anonymous-enum named-constant policy that had been a loose thread since S10.07.Pilots the workflow the remaining per-group stories (S10.13–S10.19) will follow.
Closes #381
Change Description
MISRA fixes — 9 sites, every one reviewed per the "no blind suppressions" bar
SolidSyslogCircularBuffer.c(memcpy returns discarded)(void)castSolidSyslogNullBuffer.c(SolidSyslogSender_Sendbool discarded)(void)cast —Buffer_Writeitself returnsvoidso the bool has nowhere to propagateCircularBuffer_RecordFitsAtTailinstancestatic collided across TUsNullBuffer_InstanceandPosixMessageQueueBuffer_Instanceper the S10.08 Tier 2 conventionQUEUE_NAME_PREFIXreferenced only in_Createstatic const queueNamePrefixmemcpy(uint16_t*, uint8_t*)in the CircularBuffer length header — fixing 17.7 unmasked theseAnonymous-enum policy — tree-wide decision
The
enum { NAME = value };idiom (no tag) is the project's type-safe#definereplacement. 101 sites tree-wide were flagged by clang-tidy because SCREAMING_SNAKE doesn't start with theSolidSyslogTier 1 enum-constant prefix.Decision: the anonymous-enum form is macro-equivalent, not Tier 1 / Tier 2 enum-constant-shaped. Casing follows the macro convention.
.clang-tidy—EnumConstantIgnoredRegexp: ^[A-Z][A-Z0-9_]*$added. One regex change clears all 101 sites without renaming any code; the tagged-enum rule (SolidSyslog<Class>_Constant) stays tight.docs/NAMING.md— Macros section gains "Anonymous-enum named-constant idiom" subsection making the policy explicit.Audit doc freeze
docs/misra-conformance.mdwas the S10.05 audit working document. With the cross-cutting sweeps done (S10.07–S10.11, S10.21) and per-group conformance now underway, the audit phase is closed. The doc carries a frozen header note pointing readers at the two live sources of truth (docs/misra-deviations.mdfor rationale,misra_suppressions.txtfor per-site state). Flagged for deletion at S10.20.Test Evidence
This is MISRA-conformance refactoring with no behaviour change — the bar is "existing tests stay green, gates clean".
Ran locally under the dev container:
cmake --preset debug && cmake --build --preset debug --target junit→ 1122 tests run (2 ignored), 2451 checks, 0 failurescmake --preset sanitize && cmake --build --preset sanitize --target junit→ clean, same 1120 rancmake --preset clang-debug && cmake --build --preset clang-debug --target junit→ clean, same 1120 rancmake --preset coverage && cmake --build --preset coverage --target coverage→ buffer source files 100% line + function (Buffer.c, NullBuffer.c, CircularBuffer.c, PosixMessageQueueBuffer.c)cmake --preset tidy && cmake --build --preset tidy→ clean (caught and fixed an uninitbool fitsin the 15.5 restructure)cmake --preset cppcheck && cmake --build --preset cppcheck→ cleancppcheck --addon=misra --suppressions-list=misra_suppressions.txt …over the full tree → zero buffer-file findingsclang-format --dry-run --Werror …over all C/C++ → cleanWindows / BDD / OpenSSL integration jobs are CI's responsibility per the CLAUDE.md workflow note.
Areas Affected
Core/Source/SolidSyslogBuffer.c,SolidSyslogNullBuffer.c,SolidSyslogCircularBuffer.cPlatform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c.clang-tidy(tree-wide enum-constant rule — touches every TU but no code rename)misra_suppressions.txtdocs/NAMING.md,docs/misra-deviations.md,docs/misra-conformance.mdDEVLOG.md🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Refactor
Chores