fprintf(stderr, "Interrupt transfer not completed: %s!\n", usb_strerror(transfer->status));
quit = EIO;
-
- libusb_free_transfer(transfer);
- if (cb_data) {
- if (cb_data->dev && cb_data->dev->transfer) {
- cb_data->dev->transfer = NULL;
- }
- free(cb_data);
- }
- return;
+ goto out;
}
} else {
if (cb_data && cb_data->cb) {
if (!cb_data->cb(transfer->buffer, transfer->actual_length, cb_data->data)) {
quit = EIO;
-
- libusb_free_transfer(transfer);
- if (cb_data && cb_data->dev && cb_data->dev->transfer) {
- cb_data->dev->transfer = NULL;
- free(cb_data);
- }
-
- return;
+ goto out;
}
} else {
hexdump(transfer->buffer, transfer->actual_length, "> ");
err = libusb_submit_transfer(transfer);
if (err != 0) {
fprintf(stderr, "Can't re-submit transfer: %s\n", usb_strerror(err));
- libusb_free_transfer(transfer);
- if (cb_data) {
- if (cb_data->dev)
- cb_data->dev->transfer = NULL;
- free(cb_data);
+ goto out;
+ }
+
+ return;
+
+out:
+ libusb_free_transfer(transfer);
+ if (cb_data) {
+ if (cb_data->dev && cb_data->dev->transfer) {
+ cb_data->dev->transfer = NULL;
}
+ free(cb_data);
}
}