Closed
Labels
area: driversChipset drivers (WS2812, APA102, etc)platform: teensyTeensy 3.x, 4.xpriority: mediumCode smell, missing test — fix soontype: featureNew capability or enhancement
Description
Part of #3481 (Tier 1d).
Task
Wrap the 8 file-scope diagnostic-snapshot statics in src/platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_diagnostics.cpp.hpp in fl::Singleton<T>.
Current state
SnapshotEvent s_events[MAX_EVENTS]; // L135
u8 s_eventCount = 0; // L136
u32 s_overflowCount = 0; // L137
u8 s_lastPins = 0; // L138
u8 s_lastPinCount = 0; // L139
BusyStateSnapshot s_busyState; // L140
bool s_rxPinValid = false; // L141
u8 s_rxPin = 0; // L142Approach
struct ObjectFledDiagnosticsState { ... };— collect all 8 into one struct.- Route the
snapshot(),event(),overflow()API throughfl::Singleton<ObjectFledDiagnosticsState>::instance().s_eventsetc. - Since the diagnostic buffer is written from ObjectFLED init code but NOT from an ISR (verify this — walk the call sites), the naive
Singleton<T>::instance()pattern is safe here. If any writes come from an ISR, apply the pointer-cache pattern used in #TIER-2 issues. bash compile teensy41 --examples Blink— confirm the diagnostics storage is elided from Blink.
Acceptance criteria
- File clean of
SingletonElisionCheckerwarnings. - ObjectFLED regression tests pass (bench + autoresearch).
- Blink flash size drops by ≈
sizeof(SnapshotEvent) * MAX_EVENTS + ~20 byteson teensy41.
Metadata
Metadata
Assignees
Labels
area: driversChipset drivers (WS2812, APA102, etc)platform: teensyTeensy 3.x, 4.xpriority: mediumCode smell, missing test — fix soontype: featureNew capability or enhancement
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(lint): SingletonElisionChecker — land + drive to zero violations (…
zackees commentedon Jul 28, 2026
Audited against the finding in #3754 / #3486:
fl::Singletonelision pays off only for objects with dynamic initialization (those register.init_arrayentries that pull in a ctor and resist--gc-sections). It does nothing for constant-initialized PODs — builds already pass-ffunction-sections -fdata-sections(ci/boards.py:795), so those are already dropped when unreferenced. For PODs the wrap is a net loss: storage grows by aT*, every access gains a null-check, and constant-initialization (race-free) is replaced bySingleton<T>::instance()'s hand-rolledif (!ptr), which bypasses the C++11 magic-static guard.All 8 hits here are constant-initialized PODs. None warrant migration.
objectfled_diagnostics.cpp.hpp:136-143sits innamespace fl { namespace {(internal linkage).SnapshotEvent(L110) andBusyStateSnapshot(L103) are aggregates whose every member has a constant NSDMI (const char* stage = "",u32 gpr[4] = {0,0,0,0}), so the implicit default ctor is constexpr — static init, no.init_arrayentry. The array being ~12 KB is not the issue; it is already gc-eligible.Also note the file already carries
FL_LINT_ALLOW_GLOBAL_FILEat L3 and therefore reports 0 checker hits today — this issue's own acceptance criterion is already satisfied. Wrapping infl::Singletonwould add a null-check to each of the 40+ access sites for no elision gain.Recommend closing as not-planned. See #3492 for the checker re-scope that would make this measurable.