Repository navigation
fix(rpc): value-init args_tuple in JsonArgConverter early-returns (#2722) - #2733
Conversation
) `-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]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR fixes a ChangesTuple Value-Initialization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
Closes #2722.
Summary
-Wmaybe-uninitializedfires on 7 boards (Arduino Due / SAM3X8E, RP2040, RP2350, Adafruit Feather nRF52840 Sense, Adafruit XIAO BLE Sense, nRF52840 DK, XIAO BLE Sense nRF52) becauseJsonArgConverter::convert()early-returns with the tuple beforeconvertArgs()has written to it. The default ctor leaveshead/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...)andR()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
convertArgsran. 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 ctorThe issue suggested also hardening
fl::tupleto value-init by default. That's a strictly larger blast radius (every existingfl::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 decidefl::tuple{}should be the default semantics, that's a separate, scoped change.Test plan
bash lintcleanbash test fl_chipsets_timing_traits --cpppasses (closest test to the touched path)🤖 Generated with Claude Code
Summary by CodeRabbit