Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always send at least sizeof(UWB_NOTIFICATION_DATA) bytes for notifications #281

Merged
merged 2 commits into from
May 30, 2023

Conversation

corbin-phipps
Copy link
Contributor

@corbin-phipps corbin-phipps commented May 30, 2023

Type

  • Bug fix
  • Feature addition
  • Feature update
  • Breaking change
  • Non-functional change
  • Documentation
  • Infrastructure

Goals

Currently, the handling of notifications is failing the UWB CX validation test. This happens because the CX requires a buffer of at least sizeof(UWB_NOTIFICATION_DATA) (0x50) bytes, but lpBytesReturned of DeviceIoControl returns fewer bytes. The reason for this is because UWB_NOTIFICATION_DATA has a union member, which causes sizeof to account for the largest member in the union. A specific notification of the non-largest type may actually use fewer bytes than what sizeof calculates for the union.

Therefore, the notification handling should always send at least sizeof(UWB_NOTIFICATION_DATA) bytes, not just the number of bytes actually used for a specific notification.

Technical Details

  • Changed the notification handling to resize the buffer to the maximum of bytesRequired and sizeof(UWB_NOTIFICATION_DATA).

Test Results

nocli output displays expected values, eliminating the unexpected "insufficient buffer" messages from before.

Reviewer Focus

None.

Future Work

None.

Checklist

  • Build target all compiles cleanly.
  • clang-format and clang-tidy deltas produced no new output.
  • Newly added functions include doxygen-style comment block.

@corbin-phipps corbin-phipps requested a review from a team as a code owner May 30, 2023 21:21
abeltrano
abeltrano previously approved these changes May 30, 2023
windows/devices/uwb/UwbConnector.cxx Outdated Show resolved Hide resolved
@corbin-phipps corbin-phipps merged commit 8f549a4 into develop May 30, 2023
@corbin-phipps corbin-phipps deleted the user/corbinphipps/fix-notification-handling branch May 30, 2023 22:58
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.

3 participants