Repository navigation
Conversation
The firmware-version notification handler matched only the 5-byte prefix with starts_with and then sliced data[8..], so a 5-7 byte notification panicked. Release builds use panic = "abort", so the whole app died. Extract parse_firmware_version(data) -> Option<String>. It returns None when the prefix does not match or the packet is shorter than 8 bytes. The call site uses it with if let, so the else-if chain behaves as before. Valid packets keep the same output. Verified: cargo test --release --locked (CARGO_TARGET_DIR shared) passes, including three new tests: prefix-only 5-byte packet returns None, a valid packet yields "1.2.3", and a non-matching packet returns None.
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.
What was wrong
linux-rust/src/devices/nothing.rs(firmware-version notification handler) checkeddata.starts_with(&[0x55,0x20,0x01,0x42,0x40]), which only guarantees 5 bytes, then readdata[8..]. A 5–7 byte notification with that prefix panics, andCargo.tomlsetspanic = "abort"for release builds, so the whole app exits.Fix
A small pure function
parse_firmware_version(&[u8]) -> Option<String>returnsNonewhen the prefix does not match or the packet is shorter than 8 bytes. The call site usesif let Some(..). Output for valid packets is unchanged.Verified
cd linux-rust && cargo test --release --locked:test result: ok. 3 passed; 0 failed(prefix-only 5 bytes → None, valid packet with "1.2.3" → Some, non-matching packet → None).Not verified
Not tested with a real Nothing device. #892 and #888 also edit
nothing.rs(other parts of the file) and may need a trivial rebase.🤖 Generated with Claude Code