ret = libusb_handle_events_timeout_completed(ctx->lusb_ctx, &tv, NULL);
if (ret < 0) {
- _E("Could not handle events");
+ _E("Could not handle events"); //LCOV_EXCL_LINE System Error
return FALSE;
}
if (!ch->ch) {
_E("Failed to create gio channel"); //LCOV_EXCL_LINE
free(ch); //LCOV_EXCL_LINE
- return USB_HOST_ERROR_OUT_OF_MEMORY;
+ return USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
}
ch->source_tag = g_io_add_watch(ch->ch, condition, usb_host_poll_cb, ctx);
ret = pthread_mutex_init(&_ctx->channel_list_lock, NULL);
if (ret != 0) {
_E("Failed to init mutex (%d)", ret); //LCOV_EXCL_LINE
- goto free_ctx;
+ goto free_ctx; //LCOV_EXCL_LINE
}
libusb_set_pollfd_notifiers(_ctx->lusb_ctx, fd_added_cb, fd_removed_cb, _ctx);
pollfds = libusb_get_pollfds(_ctx->lusb_ctx);
if (!pollfds) {
_E("Failed to get file descriptors for polling"); //LCOV_EXCL_LINE
- ret = USB_HOST_ERROR_OUT_OF_MEMORY;
- goto free_ctx;
+ ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ goto free_ctx; //LCOV_EXCL_LINE
}
for (i = 0; pollfds[i]; ++i) {
return USB_HOST_ERROR_NOT_SUPPORTED;
if (!context) {
- _E("Invalid parameter was passed");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter was passed"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
l = context->gio_channels;
}
if (dev->lusb_dev_handle == NULL) {
- _E("Device is not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device is not opened"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE
}
libusb_close(dev->lusb_dev_handle);
return USB_HOST_ERROR_NOT_SUPPORTED;
if (!dev || !bus_number) {
- _E("Invalid parameter was passed");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter was passed");//LCOV_EXCL_LINE
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
*bus_number = libusb_get_bus_number(dev->lusb_dev);
return USB_HOST_ERROR_NOT_SUPPORTED;
if (!dev || !device_address) {
- _E("Invalid parameter was passed");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter was passed"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
*device_address = libusb_get_device_address(dev->lusb_dev);
return USB_HOST_ERROR_NOT_SUPPORTED;
if (port_numbers_len <= 0) {
- _E("Invalid parameter was passed");
+ _E("Invalid parameter was passed"); //LCOV_EXCL_LINE
return USB_HOST_ERROR_INVALID_PARAMETER;
}
}
if (dev->lusb_dev_handle == NULL) {
- _E("Device is not opened");
+ _E("Device is not opened"); //LCOV_EXCL_LINE System Error
return USB_HOST_ERROR_DEVICE_NOT_OPENED;
}
dev = configuration->dev;
if (!dev->lusb_dev_handle) {
- _E("Device not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device not opened"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE System Error
}
ret = libusb_set_configuration(dev->lusb_dev_handle, configuration->desc.bConfigurationValue);
ret = libusb_set_configuration(dev->lusb_dev_handle, -1);
if (ret < 0) {
- _E("Could not put device in unconfigured state");
+ _E("Could not put device in unconfigured state"); //LCOV_EXCL_LINE System Error
return translate_error(ret);
}
lusb_dev_handle = interface->dev->lusb_dev_handle;
if (!lusb_dev_handle) {
- _E("Device not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device not opened"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE System Error
}
if (!force)
} else if (ret == 1) {
ret = libusb_detach_kernel_driver(lusb_dev_handle,
interface_number);
- if (ret < 0) {
+ if (ret < 0) { //LCOV_EXCL_LINE System Error
ret = translate_error(ret); //LCOV_EXCL_LINE System Error
_E("Failed to detach kernel driver(%d)", ret); //LCOV_EXCL_LINE System Error
goto out; //LCOV_EXCL_LINE System Error
interface_number = interface->altsettings[interface->altsetting].desc.bInterfaceNumber;
if (!lusb_dev_handle) {
- _E("Device not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device not opened"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE System Error
}
ret = libusb_release_interface(lusb_dev_handle, interface_number);
return USB_HOST_ERROR_NOT_SUPPORTED;
if (!dev || !protocol) {
- _E("Invalid parameter was passed");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter was passed"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE System Error
}
*protocol = dev->desc.bDeviceProtocol;
}
if (dev->lusb_dev_handle == NULL) {
- _E("Device is not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device is not opened"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE System Error
}
ret = libusb_get_string_descriptor_ascii(dev->lusb_dev_handle, desc_index, data, *length);
return USB_HOST_ERROR_NOT_SUPPORTED;
if (!config || !remote_wakeup) {
- _E("Invalid parameter was passed");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter was passed"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE System Error
}
*remote_wakeup = config->desc.bmAttributes & (1 << 5);
return USB_HOST_ERROR_NOT_SUPPORTED;
if (!config) {
- _E("Invalid parameter was passed");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter was passed"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE System Error
}
free((void *)config->extra);
if (ret < 0) {
ret = translate_error(ret); //LCOV_EXCL_LINE System Error
_E("Failed to get configuration descriptor (%d)", ret); //LCOV_EXCL_LINE System Error
- goto out;
+ goto out; //LCOV_EXCL_LINE System Error
}
cfg = malloc(sizeof(*cfg));
ret = dump_config_desc(cfg, lcfg_desc, dev);
if (ret != 0) {
- _E("dump_config_desc() failed");
- free(cfg);
+ _E("dump_config_desc() failed"); //LCOV_EXCL_LINE System Error
+ free(cfg); //LCOV_EXCL_LINE System Error
goto free_lcfg_desc; //LCOV_EXCL_LINE System Error
}
}
if (!dev->lusb_dev_handle) {
- _E("Device is not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device is not opened"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE System Error
}
ret = libusb_control_transfer(dev->lusb_dev_handle, bmRequestType, bRequest,
}
if (!dev->lusb_dev_handle) {
- _E("Device not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device not opened"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE System Error
}
ret = libusb_bulk_transfer(dev->lusb_dev_handle, endpoint, data, length,
int ret;
if (!dev || !data || !transferred) {
- _E("Invalid parameter");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Invalid parameter"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
if (!dev->lusb_dev_handle) {
- _E("Device not opened");
- return USB_HOST_ERROR_DEVICE_NOT_OPENED;
+ _E("Device not opened"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_DEVICE_NOT_OPENED; //LCOV_EXCL_LINE
}
ret = libusb_interrupt_transfer(dev->lusb_dev_handle, endpoint, data, length,
usb_host_device_h dev;
dev = alloc_device(lusb_device);
- if (!dev) {
- _E("Could not allocate device");
- return 1;
+ if (!dev) { //LCOV_EXCL_LINE System Error
+ _E("Could not allocate device"); //LCOV_EXCL_LINE System Error
+ return 1; //LCOV_EXCL_LINE System Error
}
data->cb(dev, data->user_data);
int ret;
libusb_hotplug_event lusb_events = 0;
- if (!usb_host_feature_enabled())
- return USB_HOST_ERROR_NOT_SUPPORTED;
+ if (!usb_host_feature_enabled()) //LCOV_EXCL_LINE Not supported feature
+ return USB_HOST_ERROR_NOT_SUPPORTED; //LCOV_EXCL_LINE Not supported feature
if (!cb)
return USB_HOST_ERROR_INVALID_PARAMETER;
data = calloc(1, sizeof(*data));
- if (data == NULL) {
- _E("Failed to alloc memory");
- return USB_HOST_ERROR_OUT_OF_MEMORY;
+ if (data == NULL) { //LCOV_EXCL_LINE System Error
+ _E("Failed to alloc memory"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
}
data->ctx = ctx;
LIBUSB_HOTPLUG_MATCH_ANY, lusb_hotplug_cb, data, &lusb_handle);
if (ret != LIBUSB_SUCCESS) {
- ret = translate_error(ret);
- goto out;
+ ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+ goto out; //LCOV_EXCL_LINE System Error
}
data->lusb_handle = lusb_handle;
return USB_HOST_ERROR_NONE;
out:
- free(data);
- return ret;
+ free(data); //LCOV_EXCL_LINE System Error
+ return ret; //LCOV_EXCL_LINE System Error
}
int usb_host_unset_hotplug_cb(usb_host_hotplug_h handle)
{
- if (!usb_host_feature_enabled())
+ if (!usb_host_feature_enabled()) //LCOV_EXCL_LINE Not supported feature
return USB_HOST_ERROR_NOT_SUPPORTED;
- if (!handle)
+ if (!handle) //LCOV_EXCL_LINE
return USB_HOST_ERROR_INVALID_PARAMETER;
libusb_hotplug_deregister_callback(handle->ctx->lusb_ctx, handle->lusb_handle);
rtransfer = calloc(1, sizeof(*rtransfer));
if (!rtransfer) {
- _E("Failed to alloc transfer structure");
- return USB_HOST_ERROR_OUT_OF_MEMORY;
+ _E("Failed to alloc transfer structure"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
}
transfer_data = calloc(1, sizeof(*transfer_data));
if (!transfer_data) {
- _E("Failed to alloc transfer data structure");
- ret = USB_HOST_ERROR_OUT_OF_MEMORY;
- goto free_rtransfer;
+ _E("Failed to alloc transfer data structure"); //LCOV_EXCL_LINE System Error
+ ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+ goto free_rtransfer; //LCOV_EXCL_LINE System Error
}
transfer_data->cb = callback;
rtransfer->lusb_transfer = libusb_alloc_transfer(num_iso_packets);
if (!rtransfer->lusb_transfer) {
- _E("Failed to alloc libusb transfer");
- ret = USB_HOST_ERROR_OUT_OF_MEMORY;
- goto free_transfer_data;
+ _E("Failed to alloc libusb transfer"); //LCOV_EXCL_LINE System Error
+ ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+ goto free_transfer_data; //LCOV_EXCL_LINE System Error
}
rtransfer->allocated_iso_packets = num_iso_packets;
return USB_HOST_ERROR_NONE;
free_transfer_data:
- free(transfer_data);
+ free(transfer_data); //LCOV_EXCL_LINE System Error
free_rtransfer:
- libusb_free_transfer(rtransfer->lusb_transfer);
- free(rtransfer);
+ libusb_free_transfer(rtransfer->lusb_transfer); //LCOV_EXCL_LINE System Error
+ free(rtransfer); //LCOV_EXCL_LINE System Error
return ret;
}
rtransfer = calloc(1, sizeof(*rtransfer));
if (!rtransfer) {
- _E("Failed to alloc transfer structure");
- return USB_HOST_ERROR_OUT_OF_MEMORY;
+ _E("Failed to alloc transfer structure"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
}
transfer_data = calloc(1, sizeof(*transfer_data));
if (!transfer_data) {
- _E("Failed to alloc transfer data structure");
- ret = USB_HOST_ERROR_OUT_OF_MEMORY;
- goto free_rtransfer;
+ _E("Failed to alloc transfer data structure"); //LCOV_EXCL_LINE System Error
+ ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+ goto free_rtransfer; //LCOV_EXCL_LINE System Error
}
transfer_data->cb = callback;
rtransfer->lusb_transfer = libusb_alloc_transfer(0);
if (!rtransfer->lusb_transfer) {
- _E("Failed to alloc libusb transfer");
- ret = USB_HOST_ERROR_OUT_OF_MEMORY;
- goto out;
+ _E("Failed to alloc libusb transfer"); //LCOV_EXCL_LINE System Error
+ ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+ goto out; //LCOV_EXCL_LINE System Error
}
rtransfer->allocated_iso_packets = 0;
return USB_HOST_ERROR_NONE;
out:
- free(transfer_data);
- libusb_free_transfer(rtransfer->lusb_transfer);
+ free(transfer_data); //LCOV_EXCL_LINE System Error
+ libusb_free_transfer(rtransfer->lusb_transfer); //LCOV_EXCL_LINE System Error
free_rtransfer:
- free(rtransfer);
- return ret;
+ free(rtransfer); //LCOV_EXCL_LINE System Error
+ return ret; //LCOV_EXCL_LINE System Error
}
int usb_host_transfer_get_status(usb_host_transfer_h transfer, int *status)
}
if (num_iso_packets > transfer->allocated_iso_packets) {
- _E("Too many packets");
- return USB_HOST_ERROR_INVALID_PARAMETER;
+ _E("Too many packets"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE System Error
}
transfer->lusb_transfer->num_iso_packets = num_iso_packets;
}
if (packet_number >= transfer->lusb_transfer->num_iso_packets) {
- _E("No such packet\n");
- return USB_HOST_ERROR_NOT_FOUND;
+ _E("No such packet\n"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_NOT_FOUND; //LCOV_EXCL_LINE
}
buffer_usage = transfer->iso_buffer_usage + length
- transfer->lusb_transfer->iso_packet_desc[packet_number].length;
if (buffer_usage > transfer->lusb_transfer->length) {
- _E("Buffer too short");
- return USB_HOST_ERROR_OVERFLOW;
+ _E("Buffer too short"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_OVERFLOW; //LCOV_EXCL_LINE System Error
}
transfer->iso_buffer_usage = buffer_usage;
}
if (packet_number >= transfer->lusb_transfer->num_iso_packets) {
- _E("No such packet\n");
- return USB_HOST_ERROR_NOT_FOUND;
+ _E("No such packet\n"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_NOT_FOUND; //LCOV_EXCL_LINE
}
*status = transfer->lusb_transfer->iso_packet_desc[packet_number].status;
}
if (packet_number >= transfer->lusb_transfer->num_iso_packets) {
- _E("No such packet\n");
- return USB_HOST_ERROR_NOT_FOUND;
+ _E("No such packet\n"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_NOT_FOUND; //LCOV_EXCL_LINE
}
*data = libusb_get_iso_packet_buffer(transfer->lusb_transfer, packet_number);
- if (!(*data)) {
- _E("No such packet\n");
- return USB_HOST_ERROR_NOT_FOUND;
+ if (!(*data)) { //LCOV_EXCL_LINE System Error
+ _E("No such packet\n"); //LCOV_EXCL_LINE System Error
+ return USB_HOST_ERROR_NOT_FOUND; //LCOV_EXCL_LINE System Error
}
*actual_length = transfer->lusb_transfer->iso_packet_desc[packet_number].actual_length;
}
if (packet_number >= transfer->lusb_transfer->num_iso_packets) {
- _E("No such packet\n");
- return USB_HOST_ERROR_NOT_FOUND;
+ _E("No such packet\n"); //LCOV_EXCL_LINE
+ return USB_HOST_ERROR_NOT_FOUND; //LCOV_EXCL_LINE
}
*length = transfer->lusb_transfer->iso_packet_desc[packet_number].length;
ret = libusb_submit_transfer(transfer->lusb_transfer);
if (ret < 0)
- _E("Failed to submit transfer: %d", ret);
+ _E("Failed to submit transfer: %d", ret); //LCOV_EXCL_LINE System Error
return translate_error(ret);
}
ret = libusb_cancel_transfer(transfer->lusb_transfer);
if (ret < 0)
- _E("Failed to cancel transfer: %d", ret);
+ _E("Failed to cancel transfer: %d", ret); //LCOV_EXCL_LINE System Error
return translate_error(ret);
}