Repository navigation
fix(hid-rp): gamepad and Xbox rumble reports no longer send uninitialized padding bits - #921
Merged
Merged
Conversation
…ized padding bits
GamepadInputReport kept its consumer byte as
`struct { uint8_t consumer_record : 1; uint8_t : 7; }` and
XboxRumbleOutputReport its first byte as
`struct { uint8_t enabled : 4; uint8_t : 4; }`. Unnamed bit-fields cannot be
assigned, so reset() only cleared the named bits and the padding bits carried
whatever was in memory into every report (hid_rp_gamepad_host_test's
`bytes[9] == 0` caught it, depending on the stack's contents).
Both are now plain zero-initialized bytes with bit accessors
(get_/set_consumer_record(), get_/set_enabled() masking to their bits); the
formatters use the getters. Layout and sizes are unchanged.
Tests construct the reports in 0xFF-filled storage, so the regression check is
deterministic; both fail on the old headers. A new hid_rp_tests.yml workflow
runs every hid-rp host test in CI (only the report-map test ran before).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
|
✅Static analysis result - no issues found! ✅ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
hid_rp_gamepad_host_testfailed one check,bytes[9] == 0, depending on what the stack held. It isn't a test bug: two reports really do send uninitialized bits.GamepadInputReport's consumer byte wasstruct { uint8_t consumer_record : 1; uint8_t : 7; }.XboxRumbleOutputReport's first byte wasstruct { uint8_t enabled : 4; uint8_t : 4; }.Unnamed bit-fields cannot be assigned, so
reset()cleared only the named bits, and the padding bits went out with whatever was in memory. That covers every gamepad input report, including espp's BLE / USB gamepads and the Xbox report, plus the rumble output report.The fix:
uint8_ts with bit accessors.get_/set_consumer_record()andget_/set_enabled()mask to their bits, so the padding stays 0.How has this been tested?
0xFF-filled storage (placement new) and check that the padding comes out 0. Both checks fail on the old headers and pass now.-std=c++23 -Wall -Wextra -Werror), including the previously failing one.hid_rp_tests.ymlworkflow runs every hid-rp host test in CI. Only the report-map test ran before, fromgamepad_map_tests.yml.components/hid-rp/examplebuilds for esp32s3.Types of changes
Checklist:
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.🤖 Generated with Claude Code
https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU