Skip to content

refactor: S10.12 pilot — Buffer group conformance + anonymous-enum policy#382

Merged
DavidCozens merged 1 commit into
mainfrom
refactor/s10-12-buffer-conformance
May 16, 2026
Merged

refactor: S10.12 pilot — Buffer group conformance + anonymous-enum policy#382
DavidCozens merged 1 commit into
mainfrom
refactor/s10-12-buffer-conformance

Conversation

@DavidCozens

@DavidCozens DavidCozens commented May 16, 2026

Copy link
Copy Markdown
Owner

Purpose

First per-group conformance story in E10. Resolves all warning-mode findings raised by analyze-tidy and analyze-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

Rule Sites Fix
17.7 4× in SolidSyslogCircularBuffer.c (memcpy returns discarded) (void) cast
17.7 1× in SolidSyslogNullBuffer.c (SolidSyslogSender_Send bool discarded) (void) cast — Buffer_Write itself returns void so the bool has nowhere to propagate
15.5 CircularBuffer_RecordFitsAtTail restructured to single exit point matching the project convention
5.9 2× bare instance static collided across TUs renamed to NullBuffer_Instance and PosixMessageQueueBuffer_Instance per the S10.08 Tier 2 convention
8.9 QUEUE_NAME_PREFIX referenced only in _Create moved to block-scope static const queueNamePrefix
21.15 (new) memcpy(uint16_t*, uint8_t*) in the CircularBuffer length header — fixing 17.7 unmasked these refactored to explicit little-endian byte read/write; no rule deviation needed

Anonymous-enum policy — tree-wide decision

The enum { NAME = value }; idiom (no tag) is the project's type-safe #define replacement. 101 sites tree-wide were flagged by clang-tidy because SCREAMING_SNAKE doesn't start with the SolidSyslog Tier 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-tidyEnumConstantIgnoredRegexp: ^[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.
  • D.010 (existing deviation for the cppcheck-misra rule 2.4 hit on this idiom) extended with the 2 buffer-file sites — same pattern, same documented rationale, count 6 → 8. Not a new deviation.

Audit doc freeze

docs/misra-conformance.md was 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.md for rationale, misra_suppressions.txt for 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 junit1122 tests run (2 ignored), 2451 checks, 0 failures
  • cmake --preset sanitize && cmake --build --preset sanitize --target junit → clean, same 1120 ran
  • cmake --preset clang-debug && cmake --build --preset clang-debug --target junit → clean, same 1120 ran
  • cmake --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 uninit bool fits in the 15.5 restructure)
  • cmake --preset cppcheck && cmake --build --preset cppcheck → clean
  • cppcheck --addon=misra --suppressions-list=misra_suppressions.txt … over the full tree → zero buffer-file findings
  • clang-format --dry-run --Werror … over all C/C++ → clean

Windows / BDD / OpenSSL integration jobs are CI's responsibility per the CLAUDE.md workflow note.

Areas Affected

  • Core/Source/SolidSyslogBuffer.c, SolidSyslogNullBuffer.c, SolidSyslogCircularBuffer.c
  • Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c
  • .clang-tidy (tree-wide enum-constant rule — touches every TU but no code rename)
  • misra_suppressions.txt
  • docs/NAMING.md, docs/misra-deviations.md, docs/misra-conformance.md
  • DEVLOG.md

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Enhanced developer documentation with updated naming guidelines and MISRA C:2012 conformance information, including policy documentation for named-constant patterns.
  • Refactor

    • Improved internal buffer implementations and codebase structure for enhanced reliability and maintainability across platform-specific components.
  • Chores

    • Updated code linting configuration and compliance suppression tracking.

Review Change Stack

…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>
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 952e79e2-80a0-4b6b-9ad3-3b071d516ae3

📥 Commits

Reviewing files that changed from the base of the PR and between 97b8bc6 and 3439171.

📒 Files selected for processing (9)
  • .clang-tidy
  • Core/Source/SolidSyslogCircularBuffer.c
  • Core/Source/SolidSyslogNullBuffer.c
  • DEVLOG.md
  • Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c
  • docs/NAMING.md
  • docs/misra-conformance.md
  • docs/misra-deviations.md
  • misra_suppressions.txt

📝 Walkthrough

Walkthrough

This 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 .clang-tidy enum-constant regex extension, and updated audit documentation.

Changes

Buffer-group MISRA conformance + anonymous-enum policy

Layer / File(s) Summary
CircularBuffer endianness and control-flow fixes
Core/Source/SolidSyslogCircularBuffer.c
PeekRecordSize and StoreRecord replace memcpy-based little-endian composition with explicit byte arithmetic. RecordFitsAtTail restructures to use a local fits variable and single return, matching project single-exit convention. All three functions add void casts on discarded memcpy return values.
NullBuffer static naming and return-value handling
Core/Source/SolidSyslogNullBuffer.c
TU-local singleton renamed from instance to NullBuffer_Instance following the Class_ naming convention. NullBuffer_Write adds an explicit void cast when discarding the SolidSyslogSender_Send return value.
PosixMessageQueueBuffer refactoring: static naming and scope
Platform/Posix/Source/SolidSyslogPosixMessageQueueBuffer.c
File-scope QUEUE_NAME_PREFIX constant removed; queue name prefix moved to local scope within Create. TU-local singleton renamed from instance to PosixMessageQueueBuffer_Instance. Queue lifecycle methods updated to operate on the renamed singleton.
Anonymous-enum naming policy: .clang-tidy and documentation
.clang-tidy, docs/NAMING.md
.clang-tidy extended with EnumConstantIgnoredRegexp to accept SCREAMING_SNAKE-style enum constant identifiers, clearing 101 tree-wide sites without requiring renames. docs/NAMING.md documents the anonymous-enum named-constant idiom as a type-safe macro replacement, specifying public (SOLIDSYSLOG_PascalCase) and file-scope (SCREAMING_SNAKE) casing rules and MISRA deviation coverage.
MISRA audit phase closure and tracking updates
docs/misra-conformance.md, docs/misra-deviations.md, misra_suppressions.txt, DEVLOG.md
misra-conformance.md frozen with header marking E10 audit complete; live truth redirected to per-site deviation and suppression documents. misra-deviations.md clarifies Rule 2.4 suppression interaction with Rule 5.7 (D.003). misra_suppressions.txt updated for new circular-buffer locations and POSIX refactor line numbers. Comprehensive DEVLOG.md entry documents S10.12 results, MISRA fix inventory, anonymous-enum policy decision, and audit closure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #381: S10.12 Pilot — Buffer group conformance + anonymous-enum policy — This PR directly implements the objectives of the linked issue, including all nine MISRA fixes, the anonymous-enum naming decision, and audit documentation closure.

Possibly related PRs

  • DavidCozens/solid-syslog#360: Establishes the baseline .clang-tidy tier-model for enum-constant handling; this PR extends that same configuration block with the ignored-regex rule.
  • DavidCozens/solid-syslog#376: Overlaps on Core/Source/SolidSyslogCircularBuffer.c refactoring, including changes to CircularBuffer_RecordFitsAtTail.
  • DavidCozens/solid-syslog#366: Introduces the audit-phase backlog documentation in docs/misra-conformance.md; this PR updates that same document with the audit-closure freeze header.

Poem

🐇 A rabbit's ode to buffer grace:
Eight little bytes, now rearranged with care,
Endian-explicit, no memcpy's guessing game,
Single returns and SCREAMING_SNAKE constants declare:
The audit phase closes, conformance is tame!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: refactoring for S10.12 pilot covering Buffer group conformance and anonymous-enum policy resolution.
Description check ✅ Passed The description comprehensively covers purpose, change details with supporting tables, test evidence, and affected areas, matching the template structure.
Linked Issues check ✅ Passed All nine MISRA fixes are implemented [#381], anonymous-enum policy is resolved via .clang-tidy regex [#381], documentation updated [#381], and test evidence confirms 1120+ tests passing with clean gates [#381].
Out of Scope Changes check ✅ Passed All changes align with #381 scope: Buffer cluster files, .clang-tidy (tree-wide but no code rename), docs, DEVLOG, and misra_suppressions.txt adjustments for affected files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/s10-12-buffer-conformance

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1126 passed, 🙈 2 skipped)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1246 passed, 🙈 2 skipped)
   🚦   build-linux-clang: 100% successful (✔️ 1078 passed, 🙈 2 skipped)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1078 passed, 🙈 2 skipped)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 9 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 46 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 90% successful (✔️ 44 passed, 🙈 5 skipped)
   🚦   bdd-freertos-qemu: 73% successful (✔️ 36 passed, 🙈 13 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 982 passed, 🙈 1 skipped)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1078 passed, 🙈 2 skipped)
   ⚠️   Clang-Tidy: 8 warnings (normal: 8)
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S10.12: Pilot — Buffer group conformance + anonymous-enum policy

1 participant