From: Paweł Szewczyk Date: Thu, 24 May 2018 09:44:44 +0000 (+0200) Subject: Exclude system errors handling from lcov X-Git-Tag: submit/tizen/20180531.062454~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F180082%2F2;p=platform%2Fcore%2Fapi%2Fusb-host.git Exclude system errors handling from lcov According to already existing policy, this commit excludes lines responsible for handling errors of external (system) code from line coverage. Change-Id: I97a44a493e461ad188d17709ba0a366fd417fe10 Signed-off-by: Paweł Szewczyk Signed-off-by: lokilee73 --- diff --git a/src/usb_host.c b/src/usb_host.c old mode 100644 new mode 100755 index fc38a32..308949d --- a/src/usb_host.c +++ b/src/usb_host.c @@ -398,7 +398,7 @@ static gboolean usb_host_poll_cb(GIOChannel *source, GIOCondition condition, gpo 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; } @@ -431,7 +431,7 @@ static int add_fd_watch(int fd, short events, void *user_data) 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); @@ -516,15 +516,15 @@ int usb_host_create(usb_host_context_h *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) { @@ -567,8 +567,8 @@ int usb_host_destroy(usb_host_context_h context) 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; @@ -623,8 +623,8 @@ int usb_host_device_close(usb_host_device_h dev) } 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); @@ -691,8 +691,8 @@ int usb_host_device_get_bus_number(usb_host_device_h dev, int *bus_number) 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); @@ -705,8 +705,8 @@ int usb_host_device_get_address(usb_host_device_h dev, int *device_address) 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); @@ -724,7 +724,7 @@ int usb_host_device_get_port_numbers(usb_host_device_h dev, int *port_numbers, i 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; } @@ -870,7 +870,7 @@ int usb_host_get_active_config(usb_host_device_h dev, usb_host_config_h *config) } 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; } @@ -932,8 +932,8 @@ int usb_host_set_config(usb_host_config_h configuration) 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); @@ -959,7 +959,7 @@ int usb_host_device_unconfigure(usb_host_device_h dev) 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); } @@ -985,8 +985,8 @@ int usb_host_claim_interface(usb_host_interface_h interface, bool force) 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) @@ -1005,7 +1005,7 @@ int usb_host_claim_interface(usb_host_interface_h interface, bool 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 @@ -1054,8 +1054,8 @@ int usb_host_release_interface(usb_host_interface_h interface) 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); @@ -1126,8 +1126,8 @@ int usb_host_device_get_protocol(usb_host_device_h dev, int *protocol) 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; @@ -1231,8 +1231,8 @@ static int usb_host_device_get_string_descriptor_ascii(usb_host_device_h dev, } 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); @@ -1321,8 +1321,8 @@ int usb_host_config_support_remote_wakeup(usb_host_config_h config, bool *remote 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); @@ -1561,8 +1561,8 @@ int usb_host_config_destroy(usb_host_config_h config) 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); @@ -1651,7 +1651,7 @@ int usb_host_device_get_config(usb_host_device_h dev, int config_index, usb_host 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)); @@ -1663,8 +1663,8 @@ int usb_host_device_get_config(usb_host_device_h dev, int config_index, usb_host 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 } @@ -1691,8 +1691,8 @@ int usb_host_control_transfer(usb_host_device_h dev, uint8_t bmRequestType, } 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, @@ -1720,8 +1720,8 @@ static int usb_host_bulk_transfer(usb_host_device_h dev, uint8_t endpoint, } 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, @@ -1742,13 +1742,13 @@ static int usb_host_interrupt_transfer(usb_host_device_h dev, 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, @@ -1800,9 +1800,9 @@ static int lusb_hotplug_cb(libusb_context *ctx, libusb_device *lusb_device, libu 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); @@ -1817,16 +1817,16 @@ int usb_host_set_hotplug_cb(usb_host_context_h ctx, usb_host_hotplug_cb cb, usb_ 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; @@ -1850,8 +1850,8 @@ int usb_host_set_hotplug_cb(usb_host_context_h ctx, usb_host_hotplug_cb cb, usb_ 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; @@ -1860,16 +1860,16 @@ int usb_host_set_hotplug_cb(usb_host_context_h ctx, usb_host_hotplug_cb cb, usb_ 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); @@ -1910,15 +1910,15 @@ int usb_host_create_isochronous_transfer(usb_host_endpoint_h ep, usb_host_transf 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; @@ -1927,9 +1927,9 @@ int usb_host_create_isochronous_transfer(usb_host_endpoint_h ep, usb_host_transf 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; @@ -1959,10 +1959,10 @@ int usb_host_create_isochronous_transfer(usb_host_endpoint_h ep, usb_host_transf 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; } @@ -1990,15 +1990,15 @@ int usb_host_create_control_transfer(usb_host_device_h dev, usb_host_transferred 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; @@ -2007,9 +2007,9 @@ int usb_host_create_control_transfer(usb_host_device_h dev, usb_host_transferred 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; @@ -2022,11 +2022,11 @@ int usb_host_create_control_transfer(usb_host_device_h dev, usb_host_transferred 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) @@ -2203,8 +2203,8 @@ int usb_host_transfer_set_num_iso_packets(usb_host_transfer_h transfer, unsigned } 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; @@ -2297,15 +2297,15 @@ int usb_host_transfer_set_iso_packet_length(usb_host_transfer_h transfer, unsign } 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; @@ -2325,8 +2325,8 @@ int usb_host_transfer_get_iso_packet_status(usb_host_transfer_h transfer, unsign } 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; @@ -2345,14 +2345,14 @@ int usb_host_transfer_get_iso_packet_data(usb_host_transfer_h transfer, unsigned } 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; @@ -2371,8 +2371,8 @@ int usb_host_transfer_get_iso_packet_length(usb_host_transfer_h transfer, unsign } 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; @@ -2424,7 +2424,7 @@ int usb_host_transfer_submit(usb_host_transfer_h transfer) 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); } @@ -2443,7 +2443,7 @@ int usb_host_transfer_cancel(usb_host_transfer_h transfer) 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); }