README example: prevent segmentation fault and mixture of printf/wprintf #470

Merged
endolith merged 4 commits from example_changes into master 2022-10-21 05:09:15 -05:00
endolith commented 2022-10-20 18:10:45 -05:00 (Migrated from github.com)

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

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
Youw (Migrated from github.com) reviewed 2022-10-20 18:29:41 -05:00
@ -117,22 +117,28 @@ int main(int argc, char* argv[])
// Open the device using the VID, PID,
Youw (Migrated from github.com) commented 2022-10-20 18:29:40 -05:00
		printf("Unable to open device\n");

		hid_exit()
 		return 1;
```suggestion printf("Unable to open device\n"); hid_exit() return 1; ```
Youw (Migrated from github.com) approved these changes 2022-10-20 18:29:50 -05:00
endolith (Migrated from github.com) reviewed 2022-10-20 22:52:12 -05:00
@ -117,22 +117,28 @@ int main(int argc, char* argv[])
// Open the device using the VID, PID,
endolith (Migrated from github.com) commented 2022-10-20 22:52:12 -05:00

Good point, but make the same change in the other test.c 😁

Good point, but make the same change in the other test.c 😁
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!470
No description provided.