Skip to content

windows: initialize descriptor lookup tables with memset - #862

Merged
Youw merged 4 commits into
libusb:masterfrom
ebraminio:descriptor-table-memset
Nov 25, 2026
Merged

Youw merged 4 commits into
libusb:masterfrom
ebraminio:descriptor-table-memset

Conversation

@ebraminio

Copy link
Copy Markdown
Contributor

Use explicit memset calls for the descriptor reconstruction lookup tables instead of per-element initialization loops.

The loops are equivalent on Windows: int is 32-bit two's complement, so filling each byte with 0xFF represents -1. Higher optimization levels already turn those loops into memset calls, so this makes the initialization explicit without changing behavior. C23 also mandates two's complement (N2218); the Windows compiler ABIs targeted by HIDAPI have the same representation.

Assisted-by: deepseek-harness:deepseek-flash

Replace the per-element initialization loops with explicit memset calls.
Compilers already synthesized these calls at higher optimization levels,
so this makes the intent explicit without changing behavior.

On Windows, int is a 32-bit two's complement type, so filling each byte
with 0xFF represents -1. C23 also mandates two's complement (N2218).

Assisted-by: deepseek-harness:deepseek-flash
@ebraminio

Copy link
Copy Markdown
Contributor Author

Closing as redundant: the descriptor initialization change is now required by #860 once the standard-symbol shim is removed.

@ebraminio ebraminio closed this Nov 25, 2026
@ebraminio ebraminio reopened this Nov 25, 2026

@Youw Youw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lets have this merged first, and #860 as a next step

Comment thread windows/hidapi_descriptor_reconstruct.c Resolved
Comment thread windows/hidapi_descriptor_reconstruct.c Resolved
@Youw
Youw merged commit 71c8829 into libusb:master Nov 25, 2026
20 checks passed
@mcuee mcuee added the Windows Related to Windows backend label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Windows Related to Windows backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants