Skip to content

Encapsulate wled_server.cpp's own runtime state as static, not global - #5780

Merged
netmindz merged 1 commit into
wled:mainfrom
netmindz:refactor/wledservercpp-globals
Aug 8, 2026
Merged

Encapsulate wled_server.cpp's own runtime state as static, not global#5780
netmindz merged 1 commit into
wled:mainfrom
netmindz:refactor/wledservercpp-globals

Conversation

@netmindz

@netmindz netmindz commented Aug 8, 2026

Copy link
Copy Markdown
Member

Summary

Part of an ongoing pass identifying WLED_GLOBAL declarations that are actually only referenced in one file (see #5777, #5778, #5779 for earlier ones). 4 more turned out to be private to wled_server.cpp: editHandler, messageHead, messageSub, optionType. (messageHead was declared on the same source line as messageSub but turned out to be just as single-file — verified separately before removing both.)

Converted all 4 to file-local static, same types and initial values as before.

No behavior change — purely a storage-class change.

Test plan

  • esp32dev: builds and links cleanly via pio run -e esp32dev — 1,320,323 bytes flash, no warnings.
  • Confirmed via repo-wide grep (wled00/, usermods/) that none of the 4 converted variables are referenced outside wled_server.cpp.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Encapsulated internal web-server state to limit its visibility within the application.
    • No user-facing behavior or runtime functionality changed.

4 WLED_GLOBAL variables were referenced only in wled_server.cpp:
editHandler, messageHead, messageSub, optionType (messageHead was
bundled on the same declaration line as messageSub but turned out to
be just as single-file). Converted all 4 to file-local `static`.

No behavior change - purely a storage-class change.

Verified: esp32dev builds and links cleanly via `pio run -e esp32dev`
(1,320,323 bytes flash, no warnings from either changed file).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtCyBD91vAYWvBzaMyQSHd
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The change removes four runtime-state declarations from wled.h and adds file-local static declarations in wled_server.cpp. Runtime logic remains unchanged.

Changes

Server state encapsulation

Layer / File(s) Summary
Move runtime state to server scope
wled00/wled.h, wled00/wled_server.cpp
The header no longer declares messageHead, messageSub, optionType, or editHandler. The server implementation declares these variables as file-local static state.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • wled/WLED#5777: Encapsulates implementation-specific global state in its implementation file.
  • wled/WLED#5778: Removes internal runtime globals from the public header.
  • wled/WLED#5779: Moves file-private runtime state to static implementation declarations.

Suggested labels: minor

Suggested reviewers: softhack007

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making wled_server.cpp runtime state file-local static instead of global.

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.

@netmindz
netmindz merged commit 1d36afb into wled:main Aug 8, 2026
30 checks passed
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.

2 participants