Encapsulate rolloverMillis with a read-only accessor - #5790
Conversation
rolloverMillis (millis()-rollover counter, incremented in wled.cpp's main loop) was WLED_GLOBAL. json.cpp and one usermod (quinled-an-penta) only ever read it for uptime reporting, so it gets a by-value getter - getRolloverMillis() - instead of a mutable reference: an accidental write from outside wled.cpp is now a build error instead of a silent bug. Also fixed the one external consumer found: usermods/quinled-an-penta read rolloverMillis directly (same uptime-string idiom as json.cpp, literally copy-pasted per its own comment). Updated to use the new accessor. No behavior change - purely a storage/access-pattern change. Verified: - esp32dev builds and links cleanly via `pio run -e esp32dev`. - usermods env (builds all 59 usermods, including the fixed quinled-an-penta) builds and links cleanly via `pio run -e usermods`. - Repo-wide grep confirms no remaining raw references to rolloverMillis outside wled.cpp. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 8 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
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 |
Summary
Part of an ongoing pass on
WLED_GLOBALdeclarations (see #5777-#5789, #5774/#12 for earlier ones).rolloverMillis(amillis()-rollover counter, incremented inwled.cpp's main loop) is read-only fromjson.cppand one usermod.Moved it to file-local
staticinwled.cppand exposed a by-value getter,getRolloverMillis(), rather than a mutable reference — same reasoning as #5789: since nothing outsidewled.cppwrites it, the by-value getter makes an accidental external write a build error instead of a silent bug.Also fixed the one external consumer this surfaced:
usermods/quinled-an-pentareadrolloverMillisdirectly for its own uptime string (same idiom asjson.cpp— its own comment says "From json.cpp"). Updated to use the new accessor.No behavior change — purely a storage/access-pattern change.
Test plan
esp32dev: builds and links cleanly viapio run -e esp32dev.usermodsenv (builds all 59 usermods, including the fixedquinled-an-penta): builds and links cleanly viapio run -e usermods.rolloverMillisoutsidewled.cpp.🤖 Generated with Claude Code