Skip to content

Detect inline header error instead of panicing#7

Merged
ataffanel merged 3 commits intomasterfrom
ataffanel/detect-inline-error
Feb 5, 2026
Merged

Detect inline header error instead of panicing#7
ataffanel merged 3 commits intomasterfrom
ataffanel/detect-inline-error

Conversation

@ataffanel
Copy link
Member

In case of malformed inline-mode header, the current implementation panics.

This PR adds a protocolError field to the error type and return it in that case.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to add error handling for malformed inline-mode headers instead of allowing the code to panic. It introduces a new UsbProtocolError variant to the Error enum and adds validation logic to check the received data before processing.

Changes:

  • Added UsbProtocolError(String) variant to the Error enum for USB protocol violations
  • Added validation check in send_inline function to detect malformed inline headers
  • Captures answer_size from read_bulk operation for validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bitcraze bitcraze deleted a comment from Copilot AI Feb 5, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.read_bulk(0x81, &mut answer, Duration::from_secs(1))?;

// Decode answer
// The first bye of the answer is the size of the answer
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "bye" should be "byte".

Suggested change
// The first bye of the answer is the size of the answer
// The first byte of the answer is the size of the answer

Copilot uses AI. Check for mistakes.
@ataffanel ataffanel merged commit 0f68a11 into master Feb 5, 2026
7 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.

4 participants