core: Suppress hotplug events during initial enumeration
[platform/upstream/libusb.git] / examples / hotplugtest.c
index 851915e..94f7e56 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */
 /*
  * libusb example program for hotplug API
- * Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.ccom>
+ * Copyright © 2012-2013 Nathan Hjelm <hjelmn@mac.com>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,11 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
        struct libusb_device_descriptor desc;
        int rc;
 
+       (void)ctx;
+       (void)dev;
+       (void)event;
+       (void)user_data;
+
        rc = libusb_get_device_descriptor(dev, &desc);
        if (LIBUSB_SUCCESS != rc) {
                fprintf (stderr, "Error getting device descriptor\n");
@@ -55,6 +60,11 @@ static int LIBUSB_CALL hotplug_callback(libusb_context *ctx, libusb_device *dev,
 
 static int LIBUSB_CALL hotplug_callback_detach(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *user_data)
 {
+       (void)ctx;
+       (void)dev;
+       (void)event;
+       (void)user_data;
+
        printf ("Device detached\n");
 
        if (handle) {
@@ -73,9 +83,9 @@ int main(int argc, char *argv[])
        int product_id, vendor_id, class_id;
        int rc;
 
-       vendor_id  = (argc > 1) ? strtol (argv[1], NULL, 0) : 0x045a;
-       product_id = (argc > 2) ? strtol (argv[2], NULL, 0) : 0x5005;
-       class_id   = (argc > 3) ? strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
+       vendor_id  = (argc > 1) ? (int)strtol (argv[1], NULL, 0) : 0x045a;
+       product_id = (argc > 2) ? (int)strtol (argv[2], NULL, 0) : 0x5005;
+       class_id   = (argc > 3) ? (int)strtol (argv[3], NULL, 0) : LIBUSB_HOTPLUG_MATCH_ANY;
 
        rc = libusb_init (NULL);
        if (rc < 0)
@@ -85,7 +95,7 @@ int main(int argc, char *argv[])
        }
 
        if (!libusb_has_capability (LIBUSB_CAP_HAS_HOTPLUG)) {
-               printf ("Hotplug capabilites are not supported on this platform\n");
+               printf ("Hotplug capabilities are not supported on this platform\n");
                libusb_exit (NULL);
                return EXIT_FAILURE;
        }