kinect_upload_fw: initialize current_configuration before libusb_get_configuration()
authorAntonio Ospite <ao2@ao2.it>
Tue, 5 Jan 2016 19:08:18 +0000 (20:08 +0100)
committerAntonio Ospite <ao2@ao2.it>
Tue, 5 Jan 2016 19:08:18 +0000 (20:08 +0100)
Initialize the variable as suggested by http://libusb.sourceforge.net/api-1.0/caveats.html

kinect_upload_fw/kinect_upload_fw.c

index e3b72db..f145865 100644 (file)
@@ -155,13 +155,14 @@ int main(int argc, char** argv) {
                goto fail_libusb_open;
        }
 
                goto fail_libusb_open;
        }
 
-       int current_configuration = 0;
+       int current_configuration = -1;
        libusb_get_configuration(dev, &current_configuration);
        if (current_configuration != 1)
                libusb_set_configuration(dev, 1);
 
        libusb_claim_interface(dev, 0);
 
        libusb_get_configuration(dev, &current_configuration);
        if (current_configuration != 1)
                libusb_set_configuration(dev, 1);
 
        libusb_claim_interface(dev, 0);
 
+       current_configuration = -1;
        libusb_get_configuration(dev, &current_configuration);
        if (current_configuration != 1) {
                res = -ENODEV;
        libusb_get_configuration(dev, &current_configuration);
        if (current_configuration != 1) {
                res = -ENODEV;