README example: prevent segmentation fault and mixture of printf/wprintf#470
Merged
Youw merged 4 commits intolibusb:masterfrom Oct 21, 2022
Merged
README example: prevent segmentation fault and mixture of printf/wprintf#470Youw merged 4 commits intolibusb:masterfrom
Youw merged 4 commits intolibusb:masterfrom
Conversation
It was printing only the first character. https://devblogs.microsoft.com/oldnewthing/20190830-00/?p=102823 "If you want your code to work both on runtimes that use the Windows classic printf rules as well as those that use C standard printf rules, you can limit yourself to %hs for narrow strings and %ls for wide strings, and you’ll get consistent results regardless of whether the format string was passed to sprintf or wsprintf."
When no device is connected (or user doesn't have permission to access device), hid_open returns NULL. If NULL is passed to hid_get_manufacturer_string(), it crashes with SIGSEGV, which could be confusing to newcomers trying to get example to work.
wprintf and printf aren't compatible in the same stream
Youw
reviewed
Oct 20, 2022
Youw
approved these changes
Oct 20, 2022
fengjixuchui
added a commit
to fengjixuchui/hidapi
that referenced
this pull request
Oct 21, 2022
README: prevent segmentation fault and mixture of printf/wprintf (libusb#470)
endolith
added a commit
to endolith/hidapi
that referenced
this pull request
Oct 21, 2022
Same change as libusb#470
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.
When no device is connected (or user doesn't have permission to access
device), hid_open returns NULL. If NULL is passed to
hid_get_manufacturer_string(), it crashes with SIGSEGV, which could be
confusing to newcomers trying to get example to work.
wprintf and printf aren't compatible in the same stream
Now it's more similar to https://github.com/libusb/hidapi/blob/master/hidtest/test.c#L129
Closes: #469