summaryrefslogtreecommitdiff
path: root/examples/hotplugtest.c
Commit message (Collapse)AuthorAgeFilesLines
* Update tests and example to use the new libusb_init_context() functionNathan Hjelm2023-01-201-1/+1
| | | | | | | | | This commit updates all test and example code to use the newer libusb_init_context() function instead of libusb_init(). Signed-off-by: Nathan Hjelm <hjelmn@google.com> [Tormod: Update umockdev.c as well] Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
* Fix typos detected by codespell and manual inspectionChris Dickens2020-08-181-1/+1
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* Fix unused parameter warningsSean McBride2017-12-281-0/+10
| | | | Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* examples: fix 3 compiler warningsLudovic Rousseau2016-03-061-3/+3
| | | | | | | | | | | | examples/hotplugtest.c:76:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] vendor_id = (argc > 1) ? strtol (argv[1], NULL, 0) : 0x045a; ~ ^~~~~~~~~~~~~~~~~~~~~~~~~ examples/hotplugtest.c:77:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] product_id = (argc > 2) ? strtol (argv[2], NULL, 0) : 0x5005; ~ ^~~~~~~~~~~~~~~~~~~~~~~~~ examples/hotplugtest.c:78:28: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32] class_id = (argc > 3) ? strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY; ~ ^~~~~~~~~~~~~~~~~~~~~~~~~
* Examples: fix typo in Nathan Hjelm emailLudovic Rousseau2016-01-061-1/+1
|
* Examples: Fix device leak in hotplugtestChris Dickens2015-01-121-3/+21
| | | | | | | | Device leak occurred if either of the following occured: 1) Detach followed by attach 2) Two consecutive attach Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
* examples: check the value returned by libusb_handle_events()Ludovic Rousseau2013-09-281-1/+3
| | | | | | | Problem detected by the Coverity tool CID 1042539 (#1 of 1): Unchecked return value (CHECKED_RETURN)8. check_return: Calling function "libusb_handle_events(libusb_context *)" without checking return value (as is done elsewhere 6 out of 7 times).
* examples: check the value returned by libusb_init()Ludovic Rousseau2013-09-281-1/+6
| | | | | | | Problem detected by the Coverity tool CID 1042538 (#1 of 1): Unchecked return value (CHECKED_RETURN)4. check_return: Calling function "libusb_init(libusb_context **)" without checking return value (as is done elsewhere 11 out of 12 times).
* Add some editor meta-comments for proper tab usageNathan Hjelm2013-05-151-0/+1
| | | | Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add hotplug support.Nathan Hjelm2013-05-151-0/+96
The internal API is changing as follows: - Adding two new functions. usbi_connect_device, and usbi_disconnect_device. Backends must call these functions to add them to the context's device list at one of two places: initial enumeration (done at init), and on device attach and removal. These functions need to be called once per context. - Backends that support hotplug should not provide a get_device_list funtion. This function is now deprecated and will likely be removed once all backends support hotplug. The external API is changing as follows: - Two new functions have been added to register and deregister callbacks for hotplug notification: libusb_hotplug_register_callback(), libusb_hotplug_deregister_callback(). Hotplug callbacks are called by libusb_handle_events(). Details of the new API can be found in libusb.h. - A new capability check has been added to check for hotplug support. See LIBUSB_CAP_HAS_HOTPLUG. Aa suggested by Xiaofan add new example has been added to show how to use the new external hotplug API. See examples/hotplugtest.c. Signed-off-by: Hans de Goede <hdegoede@redhat.com>