Commit graph

7 commits

Author SHA1 Message Date
Ludovic Rousseau
964cff46cc examples: fix 3 compiler warnings
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;
                   ~              ^~~~~~~~~~~~~~~~~~~~~~~~~
2016-03-06 13:42:13 +01:00
Ludovic Rousseau
e10a652b4b Examples: fix typo in Nathan Hjelm email 2016-01-06 10:20:24 +01:00
Chris Dickens
30376161e5 Examples: Fix device leak in hotplugtest
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>
2015-01-12 00:12:02 -08:00
Ludovic Rousseau
d4dabfd14e examples: check the value returned by libusb_handle_events()
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).
2013-09-28 12:16:13 +02:00
Ludovic Rousseau
aa00030b78 examples: check the value returned by libusb_init()
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).
2013-09-28 12:14:13 +02:00
Nathan Hjelm
57256dd159 Add some editor meta-comments for proper tab usage
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2013-05-15 20:43:35 +02:00
Nathan Hjelm
7801ff94fa Add hotplug support.
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>
2013-05-15 17:28:06 +02:00