Remove _CRT_SECURE_NO_WARNINGS #774

Merged
Youw merged 2 commits from dev-remove-crt-secure into master 2026-03-04 17:56:57 -06:00
Youw commented 2026-03-01 12:43:46 -06:00 (Migrated from github.com)
  • use *_s version of swprintf/wcsncpy/sscanf when possible

Fixes: #770

- use *_s version of swprintf/wcsncpy/sscanf when possible Fixes: #770
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-03-01 12:48:16 -06:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR removes reliance on _CRT_SECURE_NO_WARNINGS in the Windows backend by switching to MSVC “secure CRT” function variants where appropriate, addressing MSVC warning noise reported in #770.

Changes:

  • Removed _CRT_SECURE_NO_WARNINGS defines from Windows source/header files.
  • Introduced MSVC-version-gated wrappers to use swprintf_s / wcsncpy_s in windows/hid.c.
  • Updated the Windows HID report reconstructor test to use sscanf_s (with required buffer-size args) when building with MSVC.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
windows/test/hid_report_reconstructor_test.c Uses sscanf_s on MSVC (and passes scanset buffer sizes) to avoid CRT “unsafe” warnings.
windows/hidapi_descriptor_reconstruct.h Removes _CRT_SECURE_NO_WARNINGS define block.
windows/hid.c Removes _CRT_SECURE_NO_WARNINGS and uses MSVC secure CRT wrappers for swprintf/wcsncpy.

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

## Pull request overview This PR removes reliance on `_CRT_SECURE_NO_WARNINGS` in the Windows backend by switching to MSVC “secure CRT” function variants where appropriate, addressing MSVC warning noise reported in #770. **Changes:** - Removed `_CRT_SECURE_NO_WARNINGS` defines from Windows source/header files. - Introduced MSVC-version-gated wrappers to use `swprintf_s` / `wcsncpy_s` in `windows/hid.c`. - Updated the Windows HID report reconstructor test to use `sscanf_s` (with required buffer-size args) when building with MSVC. ### Reviewed changes Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments. | File | Description | | ---- | ----------- | | windows/test/hid_report_reconstructor_test.c | Uses `sscanf_s` on MSVC (and passes scanset buffer sizes) to avoid CRT “unsafe” warnings. | | windows/hidapi_descriptor_reconstruct.h | Removes `_CRT_SECURE_NO_WARNINGS` define block. | | windows/hid.c | Removes `_CRT_SECURE_NO_WARNINGS` and uses MSVC secure CRT wrappers for `swprintf`/`wcsncpy`. | --- 💡 <a href="/libusb/hidapi/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!774
No description provided.