Skip to content

fix(rpc): value-init args_tuple in JsonArgConverter early-returns (#2722) - #2733

Merged
zackees merged 1 commit into
masterfrom
fix/2722-value-init-args-tuple
Jun 4, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2722-value-init-args-tuple

Conversation

@zackees

@zackees zackees commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Closes #2722.

Summary

-Wmaybe-uninitialized fires on 7 boards (Arduino Due / SAM3X8E, RP2040, RP2350, Adafruit Feather nRF52840 Sense, Adafruit XIAO BLE Sense, nRF52840 DK, XIAO BLE Sense nRF52) because JsonArgConverter::convert() early-returns with the tuple before convertArgs() has written to it. The default ctor leaves head/tail (and nested tuple members) indeterminate, so the subsequent move/copy reads indeterminate memory — UB. On AVR/ARM this becomes garbage pointer values handed to RPC handlers.

Fix

One-line in two places (both R(Args...) and R() specializations):

-args_tuple tuple;
+args_tuple tuple{};

Value-initialization makes the bail-out branches (not-an-array, arg-count mismatch) return a defined tuple regardless of whether convertArgs ran. Cost: zero — at the type system level it just forces the implicit value-init the compiler should have been doing.

Why this and not also hardening fl::tuple's default ctor

The issue suggested also hardening fl::tuple to value-init by default. That's a strictly larger blast radius (every existing fl::tuple<T...> t; would change behavior) and risks performance regressions in hot paths that intentionally use the uninitialized form. The targeted fix here addresses the actual call sites that triggered the warnings; if we later decide fl::tuple{} should be the default semantics, that's a separate, scoped change.

Test plan

  • bash lint clean
  • bash test fl_chipsets_timing_traits --cpp passes (closest test to the touched path)
  • CI green on the 7 affected boards (Due, RP2040, RP2350, 4x nRF52)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling reliability in JSON RPC argument conversion by ensuring proper initialization during validation checks, reducing potential edge cases in malformed request handling.

)

`-Wmaybe-uninitialized` fires on 7 boards (Arduino Due, RP2040, RP2350,
4x nRF52) because the early-return branches in `convert()` copy
`args_tuple tuple` before `convertArgs` ever writes to it. The default
ctor leaves `head`/`tail` (and nested tuple members) indeterminate;
on AVR/ARM this becomes garbage pointer values handed to RPC handlers.

Fix: value-init the local — `args_tuple tuple{}` — so the bail-out
paths (not-an-array, arg-count mismatch) return a defined tuple
regardless of whether `convertArgs` ran. Applied to both the
`R(Args...)` and `R()` specializations.

Closes #2722.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e407ee8f-5c04-461a-b754-265c8da6f668

📥 Commits

Reviewing files that changed from the base of the PR and between ae6785b and 5d2ce54.

📒 Files selected for processing (1)
  • src/fl/remote/rpc/json_arg_converter.h

📝 Walkthrough

Walkthrough

This PR fixes a -Wmaybe-uninitialized compiler warning in the JSON argument converter by value-initializing tuple result variables before early-return validation checks, ensuring tuples are never read in indeterminate state when conversion fails.

Changes

Tuple Value-Initialization

Layer / File(s) Summary
Early-return tuple value-initialization
src/fl/remote/rpc/json_arg_converter.h
JsonArgConverter<R(Args...)>::convert and the JsonArgConverter<R()>::convert specialization now value-initialize args_tuple with tuple{} before performing non-array and argument-count validations, ensuring safe early returns on type mismatch or argument count mismatch.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A tuple once lived uninitialized and lost,
Early returns would read it—undefined at cost.
Now with braces {} it's born aware,
Each error path returns a value fair.
Happy hopping through the validation code!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: value-initializing args_tuple in JsonArgConverter early-returns, which directly addresses the -Wmaybe-uninitialized warning mentioned in issue #2722.
Linked Issues check ✅ Passed The PR implements the exact fix proposed in issue #2722: replacing args_tuple tuple; with args_tuple tuple{} to value-initialize the tuple and prevent undefined behavior from uninitialized members being read on early-return paths.
Out of Scope Changes check ✅ Passed All changes are focused on the specific fix for issue #2722; modifications to json_arg_converter.h directly address the -Wmaybe-uninitialized warning without introducing unrelated changes.

✏️ 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 fix/2722-value-init-args-tuple

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.

@zackees
zackees merged commit 3df21f0 into master Jun 4, 2026
8 of 9 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 4, 2026
@zackees
zackees deleted the fix/2722-value-init-args-tuple branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CRITICAL: -Wmaybe-uninitialized fl::tuple read in json_arg_converter.h:76 (Due, RP2040/RP2350, 4x nRF52)

1 participant