Skip to content

refactor: S10.16 Senders conformance#426

Merged
DavidCozens merged 6 commits into
mainfrom
refactor/s10-16-senders
May 22, 2026
Merged

refactor: S10.16 Senders conformance#426
DavidCozens merged 6 commits into
mainfrom
refactor/s10-16-senders

Conversation

@DavidCozens

@DavidCozens DavidCozens commented May 22, 2026

Copy link
Copy Markdown
Owner

Purpose

Closes #389. Fifth per-group conformance story in E10, applying the S10.12 pilot recipe to the Senders cluster (Sender, NullSender, UdpSender, StreamSender, SwitchingSender, UdpPayload, plus the E11 three-TU split files for the three pool-backed senders). The aim is zero in-scope cppcheck-misra and clang-tidy findings after the work, with each existing suppression re-justified per-site and any genuine local defect fixed instead of carried as a deviation.

Change Description

Started from the CI cppcheck-misra report against main@ddbc81f (run 26293233352). analyze-tidy was already clean against the cluster; all work was on the cppcheck-misra side. Six unsuppressed findings split into:

  • Four anchor drifts in misra_suppressions.txt. The 11.3 / 11.5 vtable-cast suppressions were anchored at the closing } of the inline SelfFromBase (or the comment line for 11.5) instead of the cast-expression line cppcheck reports against. The 5.7 anchor on the StreamSender anonymous enum was at the first constant rather than the {. SwitchingSender:59 matched by coincidence — its cast and brace are on the same line. One-line bumps.
  • One genuine 17.8 fix at UdpPayload.c:37: the length parameter was being mutated in-place. Introduced a local trimmed copy and return that instead. The audit anticipated this site; the three sibling 17.8 sites in SolidSyslogFormatter.c belong to S10.19.
  • One family-wide 8.9 sweep. NullSender.c:11 flagged the file-scope static struct SolidSyslogSender instance = {...} as only-used-by-_Get(). The same finding fires on all 12 sister null-objects (NullBuffer, NullStore, NullDatagram, NullStream, NullSd, NullMutex, NullSecurityPolicy, NullAtomicCounter, NullBlockDevice, NullFile, NullResolver, plus NullSender). None were previously suppressed, so the cluster was known-pending. Discussed with David — chose to sweep all 12 in this story (fix-when-we-see-it) rather than spread it across S10.17–S10.19. The instance moves inside the accessor as a function-scope static; lifetime and address stability are identical. No new deviation.
  • D.009 widened to cover rule 5.7 in addition to 2.4. cppcheck-misra fires both rules on the same anonymous-enum named-constant idiom for the same syntactic shape. The three Senders-scope 5.7-on-anonymous-enum suppressions (UdpPayload.h:15, StreamSender.c:19, UdpPayload.c:5) migrated from the D.003 block (struct-tag repetition) to the D.009 block. Other historical 5.7-on-anonymous-enum suppressions stay in D.003 until S10.17 / S10.18 / S10.19 review their clusters — D.009's wording now states that the deviation authorising each 5.7 line is determined by the identifier kind, not by the physical block.
  • Cppcheck dedup follow-up. After fixing the 5.7 anchor at StreamSender.c:19, a 2.4 finding surfaced on the same line — previously masked by the matching (mis-anchored) 5.7. The existing 2.4 suppression at :20 bumped to :19. Worth noting for the rest of E10: removing or moving one suppression can unmask another on the same source line.

Six commits on the branch — one per logical cluster. Full per-site notes in the DEVLOG entry on this branch.

Test Evidence

  • debug build clean.
  • sanitize (ASan + UBSan) clean; 1290 / 1290 tests pass.
  • tidy preset clean (zero in-scope warnings, unchanged from starting state).
  • cppcheck-misra (with --suppressions-list=misra_suppressions.txt) clean — zero in-scope findings; verified against the same ghcr.io/davidcozens/cpputest:sha-18f19e1 image the CI uses.
  • coverage 99.9% (2921 / 2925 lines, 602 / 602 functions). The four uncovered lines sit in BlockStoreStatic.c and PosixMutex.c — pre-existing, not in scope, no changed file lost coverage.
  • clang-format clean tree-wide.

Areas Affected

  • Core/Source/SolidSyslogUdpPayload.c — production fix for rule 17.8 (local copy of the length parameter).
  • Core/Source/SolidSyslogNull*.c (12 files) — production refactor for rule 8.9 (file-scope instance moved into _Get() as a function-scope static). No semantic change.
  • misra_suppressions.txt — five anchor bumps; three 5.7 lines migrated from the D.003 block to the D.009 block; one comment header updated.
  • docs/misra-deviations.md — D.009 title and rule statement widened to cover rules 2.4 + 5.7; a new "suppression-file layout" note explains the in-progress migration.
  • DEVLOG.md — entry recording the per-site decisions and the dedup follow-up.

No public-API changes. Downstream callers of SolidSyslogNullSender_Get() (and sister null-object accessors) get the exact same pointer they did before — block-scope static with a constant initializer is identical to file-scope static in lifetime and address.

Summary by CodeRabbit

  • Refactor

    • Optimized singleton pattern implementation across multiple internal components.
    • Improved UTF-8 boundary handling in payload trimming logic.
  • Documentation

    • Added development log entry documenting S10.16 Senders conformance closure.
    • Expanded MISRA compliance deviation documentation and updated suppression mappings.

Review Change Stack

cppcheck-misra reports rule 11.3 / 11.5 / 5.7 at the cast-expression /
opening-brace line, not at the closing `}` or first enum constant.
The senders-cluster suppressions had drifted one line during the E11
three-TU split. SwitchingSender:59 happens to match by coincidence
(its cast and closing brace are on the same source line).

No behaviour change; suppressions only.
cppcheck-misra fires both 2.4 (unused tag) and 5.7 (non-unique tag) on
the same anonymous-enum named-constant idiom. The two findings share
one syntactic shape and one rationale, so they belong under one
deviation.

D.009 now documents both rules. The three 5.7-on-anonymous-enum
suppressions in the senders scope (UdpPayload.h, UdpPayload.c,
StreamSender.c) move from the D.003 block (struct-tag repetition) to
the D.009 block. D.003's wording stays narrowly about struct tags.

Other historical 5.7-on-anonymous-enum sites in the D.003 block will
migrate to D.009 as S10.17 / S10.18 / S10.19 review their clusters.
The deviation that authorises each line is determined by the kind of
identifier it lands on, not by the physical block — both blocks
correctly authorise their respective sites during the transition.
…dary

Introduce a local `trimmed` shadowing the `length` parameter so the
parameter itself is not modified. Same logic, satisfies MISRA 17.8
(function parameter should not be modified).

This is the senders-cluster site flagged by the S10.05 audit; the
three sibling 17.8 sites in SolidSyslogFormatter.c will be fixed in
S10.19.
Each null-object's singleton `instance` was declared at file scope but
only referenced inside its `_Get()` accessor. MISRA 8.9 (an object
should be defined at block scope if its identifier only appears in a
single function) is satisfied by moving the declaration inside the
accessor as a function-scope `static`. Lifetime and address stability
are identical — `static` inside a function still has program-duration
storage and a fixed address, so callers continue to receive the same
pointer on every call.

Twelve sites swept tree-wide:

- NullAtomicCounter, NullBlockDevice, NullBuffer, NullDatagram,
  NullFile, NullMutex, NullResolver, NullSd, NullSecurityPolicy,
  NullSender, NullStore, NullStream.

S10.16 scope is Senders only; the other eleven sister null-objects
are picked up here because the finding-fix-when-we-see-it strategy
costs less than splitting it across S10.17 / S10.18 / S10.19. No
new deviation is needed — MISRA 8.9 is now satisfied across the
whole null-object family.
…enum

cppcheck-misra reports rule 2.4 ("unused tag") at the `{` opening line
of an anonymous enum (consistent with how it reports 5.7), not at the
first constant. The StreamSender suppression was anchored at line 20
(the first constant) and worked only because the matching 5.7
suppression on the same site shadowed it via cppcheck's dedup. Once
S10.16 commit ca76268 corrected the 5.7 anchor to line 19, the 2.4
finding surfaced.

Bumping the 2.4 suppression line :20 → :19. Sister anonymous-enum
2.4 suppressions (BlockSequence.c:13, RecordStore.c:14,
Transport.h:5) already match this convention.
Records the per-group review outcome, the two decisions taken at
the bend (sweep all 12 null-objects, widen D.009 to 2.4 + 5.7), and
the cppcheck dedup follow-up that surfaced a second anchor drift on
the StreamSender anonymous enum.
@coderabbitai

coderabbitai Bot commented May 22, 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: 057c0640-614f-417e-a1a7-e54daaa8eb83

📥 Commits

Reviewing files that changed from the base of the PR and between ddbc81f and 369a752.

📒 Files selected for processing (16)
  • Core/Source/SolidSyslogNullAtomicCounter.c
  • Core/Source/SolidSyslogNullBlockDevice.c
  • Core/Source/SolidSyslogNullBuffer.c
  • Core/Source/SolidSyslogNullDatagram.c
  • Core/Source/SolidSyslogNullFile.c
  • Core/Source/SolidSyslogNullMutex.c
  • Core/Source/SolidSyslogNullResolver.c
  • Core/Source/SolidSyslogNullSd.c
  • Core/Source/SolidSyslogNullSecurityPolicy.c
  • Core/Source/SolidSyslogNullSender.c
  • Core/Source/SolidSyslogNullStore.c
  • Core/Source/SolidSyslogNullStream.c
  • Core/Source/SolidSyslogUdpPayload.c
  • DEVLOG.md
  • docs/misra-deviations.md
  • misra_suppressions.txt

📝 Walkthrough

Walkthrough

Null-component getter functions move singleton instances from file scope to function-local scope across twelve implementations. UDP payload trimming refactors parameter handling to use local variables. DEVLOG, deviation documentation, and suppression tracking are updated to record conformance closure and line-number adjustments.

Changes

S10.16 Senders Conformance Closure

Layer / File(s) Summary
Null singleton instance refactoring
Core/Source/SolidSyslogNullAtomicCounter.c, SolidSyslogNullBlockDevice.c, SolidSyslogNullBuffer.c, SolidSyslogNullDatagram.c, SolidSyslogNullFile.c, SolidSyslogNullMutex.c, SolidSyslogNullResolver.c, SolidSyslogNullSd.c, SolidSyslogNullSecurityPolicy.c, SolidSyslogNullSender.c, SolidSyslogNullStore.c, SolidSyslogNullStream.c
All twelve null-component *_Get() functions move their static singleton instances from file scope into function-local scope with designated initializers. Returned pointers and vtable/callback behavior remain identical.
UDP payload trimming refactoring
Core/Source/SolidSyslogUdpPayload.c
SolidSyslogUdpPayload_TrimToCodepointBoundary no longer modifies the length parameter directly; it introduces a local trimmed variable, applies UTF-8 last-codepoint boundary logic, and returns the adjusted result.
Conformance documentation and suppression tracking
DEVLOG.md, docs/misra-deviations.md, misra_suppressions.txt
DEVLOG documents S10.16 closure with acceptance criteria and validation results. misra_suppressions.txt updates line anchors and migrates Rule 5.7 anonymous-enum suppressions from D.003 to D.009. docs/misra-deviations.md extends D.009 to cover Rules 2.4 and 5.7 for the anonymous-enum named-constant pattern.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • DavidCozens/solid-syslog#407: Modifies the same null-component getter implementations with singleton/vtable instance scope and initialization refactoring patterns.
  • DavidCozens/solid-syslog#384: Overlaps on SolidSyslogNullMutex.c and SolidSyslogNullSecurityPolicy.c with the same singleton storage and function-pointer initialization relocation.
  • DavidCozens/solid-syslog#376: Modifies SolidSyslogUdpPayload.c at the same function (TrimToCodepointBoundary), adjusting UTF-8 boundary logic.

Poem

🐰 Static singletons hop inside their homes at last,
No longer sprawled across the file-scope grass,
Each getter births its instance fresh and neat,
While payload trims its bytes to codepoint beat.
Conformance closed, the deviations set in stone,
The null components rest, forever scoped and known. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 "refactor: S10.16 Senders conformance" directly and accurately describes the main change: applying conformance workflow to the Senders cluster to resolve MISRA findings.
Description check ✅ Passed The description covers Purpose (closes #389), Change Description (detailed breakdown of all changes), Test Evidence (comprehensive results across all presets), and Areas Affected (modules and interfaces touched). All template sections are well-populated.
Linked Issues check ✅ Passed PR fully implements all coding objectives from #389: fixed four anchor drifts [#389], fixed genuine MISRA 17.8 defect in UdpPayload.c [#389], swept 12 Null* files for MISRA 8.9 [#389], widened D.009 deviation [#389], migrated suppressions [#389], zero new findings across all gates [#389].
Out of Scope Changes check ✅ Passed All changes align with S10.16 scope: Senders cluster files, MISRA deviation documentation, and DEVLOG. No platform helpers, network primitives, storage stack, or engine/formatter changes (S10.17-S10.20 scope).

✏️ 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-16-senders

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 (✔️ 1296 passed, 🙈 2 skipped)
   🚦   build-freertos-host-tdd: 100% successful (✔️ 1518 passed, 🙈 2 skipped)
   🚦   build-linux-clang: 100% successful (✔️ 1248 passed, 🙈 2 skipped)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1248 passed, 🙈 2 skipped)
   🚦   integration-linux-openssl: 100% successful (✔️ 9 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 7 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: 86% successful (✔️ 42 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1136 passed, 🙈 1 skipped)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1248 passed, 🙈 2 skipped)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


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

@DavidCozens DavidCozens merged commit e742560 into main May 22, 2026
21 checks passed
@DavidCozens DavidCozens deleted the refactor/s10-16-senders branch May 22, 2026 16:17
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.16: Senders conformance

1 participant