coverage: remove system error logs from the coverage test 78/89878/1 accepted/tizen/3.0/common/20161114.105339 accepted/tizen/3.0/ivi/20161011.053453 accepted/tizen/3.0/mobile/20161015.032624 accepted/tizen/3.0/tv/20161016.004126 accepted/tizen/common/20161021.194020 accepted/tizen/ivi/20160929.001655 accepted/tizen/mobile/20160929.001515 accepted/tizen/tv/20160929.001709 submit/tizen/20160927.110043 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000000 submit/tizen_3.0_ivi/20161010.000010 submit/tizen_3.0_mobile/20161015.000001 submit/tizen_3.0_tv/20161015.000001 submit/tizen_common/20161021.175024
authortaeyoung <ty317.kim@samsung.com>
Tue, 27 Sep 2016 09:12:42 +0000 (18:12 +0900)
committertaeyoung <ty317.kim@samsung.com>
Tue, 27 Sep 2016 09:12:42 +0000 (18:12 +0900)
Change-Id: I14884b4715e110e6e1c6ad2f3d51273469ad431e
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/usb_host.c

index 53cebc5b5018244f6065955e5c60fcde581980d2..7da0d1f6ca39150212db0977494fd9d3f5ce2cd6 100644 (file)
@@ -45,8 +45,8 @@ static int usb_host_feature_enabled(void)
        if (ret == SYSTEM_INFO_ERROR_NONE && val)
                enabled = 1;
        else {
-               _E("USB Host API is not supported");
-               enabled = 0;
+               _E("USB Host API is not supported"); //LCOV_EXCL_LINE Not supported feature
+               enabled = 0; //LCOV_EXCL_LINE Not supported feature
        }
 
        return enabled;
@@ -115,8 +115,8 @@ static struct usb_host_device_s *alloc_device(libusb_device *lusb_dev)
 
        dev = calloc(1, sizeof(*dev));
        if (!dev) {
-               _E("malloc() failed");
-               goto out;
+               _E("malloc() failed"); //LCOV_EXCL_LINE System error
+               goto out; //LCOV_EXCL_LINE System error
        }
 
        uref_init(&dev->ref, free_device);
@@ -126,10 +126,10 @@ static struct usb_host_device_s *alloc_device(libusb_device *lusb_dev)
 
        ret = libusb_get_device_descriptor(lusb_dev, &dev->desc);
        if (ret < 0) {
-               _E("could not get device descriptor");
-               libusb_unref_device(lusb_dev);
-               free(dev);
-               return NULL;
+               _E("could not get device descriptor"); //LCOV_EXCL_LINE System error
+               libusb_unref_device(lusb_dev); //LCOV_EXCL_LINE System error
+               free(dev); //LCOV_EXCL_LINE System error
+               return NULL; //LCOV_EXCL_LINE System error
        }
 
 out:
@@ -172,8 +172,8 @@ static int dump_extra(const unsigned char *src, int src_len,
                extra_length = src_len;
                extra = malloc(extra_length);
                if (!extra) {
-                       _E("malloc() failed");
-                       goto out;
+                       _E("malloc() failed"); //LCOV_EXCL_LINE System error
+                       goto out; //LCOV_EXCL_LINE System error
                }
 
                memcpy(extra, src, extra_length);
@@ -236,35 +236,37 @@ static int dump_altsetting(struct usb_host_altsetting_s *dest,
        dest->num_endpoints = dest->desc.bNumEndpoints;
        eps = calloc(dest->desc.bNumEndpoints, sizeof(*eps));
        if (!eps) {
-               _E("calloc() failed");
-               goto out;
+               _E("calloc() failed"); //LCOV_EXCL_LINE System error
+               goto out; //LCOV_EXCL_LINE System error
        }
 
        for (i = 0; i < dest->desc.bNumEndpoints; ++i) {
                ret = dump_ep_desc(eps + i, src->endpoint + i, dev);
                if (ret != 0) {
-                       _E("dump_ep_desc() failed (%d)", ret);
-                       goto free_eps;
+                       _E("dump_ep_desc() failed (%d)", ret); //LCOV_EXCL_LINE
+                       goto free_eps; //LCOV_EXCL_LINE
                }
        }
 
        ret = dump_extra(src->extra, src->extra_length,
                         &(dest->extra), &(dest->extra_length));
        if (ret) {
-               _E("dump_extra() failed (%d)", ret);
-               goto free_eps;
+               _E("dump_extra() failed (%d)", ret); //LCOV_EXCL_LINE
+               goto free_eps; //LCOV_EXCL_LINE
        }
 
        dest->endpoints = eps;
 
        return 0;
 
+//LCOV_EXCL_START System Error
 free_eps:
        while (--i >= 0)
                free_ep(eps + i);
        free(eps);
 out:
        return ret;
+//LCOV_EXCL_STOP
 }
 
 static int dump_interface(struct usb_host_interface_s *dest,
@@ -278,8 +280,8 @@ static int dump_interface(struct usb_host_interface_s *dest,
        dest->num_altsettings = src->num_altsetting;
        alts = calloc(dest->num_altsettings, sizeof(*alts));
        if (!alts) {
-               _E("calloc() failed");
-               goto out;
+               _E("calloc() failed"); //LCOV_EXCL_LINE System error
+               goto out; //LCOV_EXCL_LINE System error
        }
 
        dest->dev = dev;
@@ -287,8 +289,8 @@ static int dump_interface(struct usb_host_interface_s *dest,
        for (i = 0; i < dest->num_altsettings; ++i) {
                ret = dump_altsetting(alts + i, src->altsetting + i, dev);
                if (ret != 0) {
-                       _E("dump_interface_desc() failed (%d)", ret);
-                       goto free_alts;
+                       _E("dump_interface_desc() failed (%d)", ret); //LCOV_EXCL_LINE
+                       goto free_alts; //LCOV_EXCL_LINE
                }
        }
 
@@ -297,12 +299,14 @@ static int dump_interface(struct usb_host_interface_s *dest,
 
        return 0;
 
+//LCOV_EXCL_START System Error
 free_alts:
        while (--i >= 0)
                free_altsetting(alts + i);
        free(alts);
 out:
        return ret;
+//LCOV_EXCL_STOP
 }
 
 static int dump_config_desc(struct usb_host_config_s *dest,
@@ -329,35 +333,37 @@ static int dump_config_desc(struct usb_host_config_s *dest,
        dest->num_interfaces = dest->desc.bNumInterfaces;
        interfaces = calloc(dest->desc.bNumInterfaces, sizeof(*interfaces));
        if (!interfaces) {
-               _E("calloc() failed");
-               goto out;
+               _E("calloc() failed"); //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        for (i = 0; i < dest->desc.bNumInterfaces; ++i) {
                ret = dump_interface(interfaces + i, src->interface + i, dev);
                if (ret != 0) {
-                       _E("dump_interface() failed");
-                       goto free_interfaces;
+                       _E("dump_interface() failed"); //LCOV_EXCL_LINE
+                       goto free_interfaces; //LCOV_EXCL_LINE
                }
        }
 
        ret = dump_extra(src->extra, src->extra_length,
                         &(dest->extra), &(dest->extra_length));
        if (ret) {
-               _E("dump_extra() failed");
-               goto free_interfaces;
+               _E("dump_extra() failed"); //LCOV_EXCL_LINE
+               goto free_interfaces; //LCOV_EXCL_LINE
        }
 
        dest->interfaces = interfaces;
 
        return 0;
 
+//LCOV_EXCL_START System Error
 free_interfaces:
        while (--i >= 0)
                free_interface(interfaces + i);
        free(interfaces);
 out:
        return ret;
+//LCOV_EXCL_STOP
 }
 
 int usb_host_create(usb_host_context_h *ctx)
@@ -376,8 +382,8 @@ int usb_host_create(usb_host_context_h *ctx)
 
        _ctx = malloc(sizeof(*_ctx));
        if (!_ctx) {
-               _E("malloc() failed");
-               goto out;
+               _E("malloc() failed"); //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        do {
@@ -386,19 +392,21 @@ int usb_host_create(usb_host_context_h *ctx)
        } while (ret == LIBUSB_ERROR_OTHER && count > 0);
 
        if (ret < 0) {
-               _E("Failed to init libusb (%d)", ret);
-               goto free_ctx;
+               _E("Failed to init libusb (%d)", ret); //LCOV_EXCL_LINE
+               goto free_ctx; //LCOV_EXCL_LINE
        }
 
        *ctx = _ctx;
 
        return USB_HOST_ERROR_NONE;
 
+//LCOV_EXCL_START System Error
 free_ctx:
        free(_ctx);
        ret = translate_error(ret);
 out:
        return ret;
+//LCOV_EXCL_STOP
 }
 
 int usb_host_destroy(usb_host_context_h context)
@@ -431,8 +439,8 @@ int usb_host_device_open(usb_host_device_h dev)
 
        ret = libusb_open(dev->lusb_dev, &(dev->lusb_dev_handle));
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to open device using libusb_open (%d)", ret);
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to open device using libusb_open (%d)", ret); //LCOV_EXCL_LINE System Error
        }
 
        return ret;
@@ -478,23 +486,23 @@ int usb_host_device_open_with_vid_pid(usb_host_context_h ctx,
        ldev_handle = libusb_open_device_with_vid_pid(ctx->lusb_ctx,
                                                      vendor_id, product_id);
        if (ldev_handle == NULL) {
-               _E("Failed to open usb device with vid and pid");
-               r = USB_HOST_ERROR_NO_SUCH_DEVICE;
-               goto out;
+               _E("Failed to open usb device with vid and pid"); //LCOV_EXCL_LINE System Error
+               r = USB_HOST_ERROR_NO_SUCH_DEVICE; //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        ldev = libusb_get_device(ldev_handle);
        if (!ldev) {
-               _E("Failed to get device");
-               r = USB_HOST_ERROR_NO_SUCH_DEVICE;
-               goto close_handle;
+               _E("Failed to get device"); //LCOV_EXCL_LINE System Error
+               r = USB_HOST_ERROR_NO_SUCH_DEVICE; //LCOV_EXCL_LINE System Error
+               goto close_handle; //LCOV_EXCL_LINE System Error
        }
 
        dev = alloc_device(ldev);
        if (!dev) {
-               _E("Failed to allocate memory for a device");
-               r = USB_HOST_ERROR_OUT_OF_MEMORY;
-               goto close_handle;
+               _E("Failed to allocate memory for a device"); //LCOV_EXCL_LINE
+               r = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+               goto close_handle; //LCOV_EXCL_LINE
        }
 
        dev->lusb_dev_handle = ldev_handle;
@@ -502,11 +510,13 @@ int usb_host_device_open_with_vid_pid(usb_host_context_h ctx,
        *device_handle = dev;
        return USB_HOST_ERROR_NONE;
 
+//LCOV_EXCL_START System Error
 close_handle:
        libusb_close(ldev_handle);
 out:
        _E("Failed to open device with given parameters");
        return r;
+//LCOV_EXCL_STOP
 }
 
 int usb_host_device_get_bus_number(usb_host_device_h dev, int *bus_number)
@@ -584,23 +594,23 @@ int usb_host_get_device_list(usb_host_context_h context, usb_host_device_h **dev
 
        len = libusb_get_device_list(context->lusb_ctx, &lusb_list);
        if (len < 0) {
-               ret = translate_error(len);
-               _E("Failed to get device list(%d)", ret);
-               goto out;
+               ret = translate_error(len); //LCOV_EXCL_LINE
+               _E("Failed to get device list(%d)", ret); //LCOV_EXCL_LINE
+               goto out; //LCOV_EXCL_LINE
        }
 
        list = calloc(len + 1, sizeof(*list));
        if (!list) {
-               _E("calloc() failed");
-               goto free_lusb_list;
+               _E("calloc() failed"); //LCOV_EXCL_LINE System Error
+               goto free_lusb_list; //LCOV_EXCL_LINE System Error
        }
 
        list[len] = NULL;
        for (i = 0; i < len; i++) {
                rdevice = alloc_device(lusb_list[i]);
                if (!rdevice) {
-                       _E("Failed to allocate memory for a device");
-                       goto free_dev_list;
+                       _E("Failed to allocate memory for a device"); //LCOV_EXCL_LINE
+                       goto free_dev_list; //LCOV_EXCL_LINE
                }
 
                list[i] = rdevice;
@@ -612,6 +622,7 @@ int usb_host_get_device_list(usb_host_context_h context, usb_host_device_h **dev
        *length = len;
        return USB_HOST_ERROR_NONE;
 
+//LCOV_EXCL_START System Error
 free_dev_list:
        while (--i >= 0)
                usb_host_unref_device(list[i]);
@@ -620,6 +631,7 @@ free_lusb_list:
        libusb_free_device_list(lusb_list, 1);
 out:
        return ret;
+//LCOV_EXCL_STOP
 }
 
 int usb_host_ref_device(usb_host_device_h dev)
@@ -668,7 +680,7 @@ int usb_host_free_device_list(usb_host_device_h *devs, bool unref_devices)
                for (i = 0; devs[i] != NULL; i++) {
                        ret = usb_host_unref_device(devs[i]);
                        if (ret < 0)
-                               return ret;
+                               return ret; //LCOV_EXCL_LINE
                }
 
        free(devs);
@@ -693,29 +705,29 @@ int usb_host_get_active_config(usb_host_device_h dev, usb_host_config_h *config)
 
        ret = libusb_get_configuration(dev->lusb_dev_handle, &cfg_nmb);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to get configuration(%d)", ret);
-               goto out;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to get configuration(%d)", ret); //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        ret = libusb_get_config_descriptor_by_value(dev->lusb_dev, cfg_nmb, &lcfg_desc);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to get configuration descriptor (%d)", ret);
-               goto out;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to get configuration descriptor (%d)", ret); //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        cfg = malloc(sizeof(*cfg));
        if (!cfg) {
-               _E("malloc() failed");
-               ret = USB_HOST_ERROR_OUT_OF_MEMORY;
-               goto free_lcfg_desc;
+               _E("malloc() failed"); //LCOV_EXCL_LINE System Error
+               ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+               goto free_lcfg_desc; //LCOV_EXCL_LINE System Error
        }
 
        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
+               free(cfg); //LCOV_EXCL_LINE
        }
 
        *config = cfg;
@@ -748,8 +760,8 @@ int usb_host_set_config(usb_host_config_h configuration)
 
        ret = libusb_set_configuration(dev->lusb_dev_handle, configuration->desc.bConfigurationValue);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to set configuration(%d)", ret);
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to set configuration(%d)", ret); //LCOV_EXCL_LINE System Error
        }
 
        return ret;
@@ -788,16 +800,16 @@ int usb_host_claim_interface(usb_host_interface_h interface, bool force)
        ret = libusb_kernel_driver_active(lusb_dev_handle,
                                          interface_number);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to activate kernel driver (%d)", ret);
-               goto out;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to activate kernel driver (%d)", ret); //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        } else if (ret == 1) {
                ret = libusb_detach_kernel_driver(lusb_dev_handle,
                                                  interface_number);
                if (ret < 0) {
-                       ret = translate_error(ret);
-                       _E("Failed to detach kernel driver(%d)", ret);
-                       goto out;
+                       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
                }
 
                driver_detached = 1;
@@ -806,21 +818,23 @@ int usb_host_claim_interface(usb_host_interface_h interface, bool force)
 claim_interface:
        ret = libusb_claim_interface(lusb_dev_handle, interface_number);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to claim interface (%d)", ret);
-               goto claim_failed;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to claim interface (%d)", ret); //LCOV_EXCL_LINE System Error
+               goto claim_failed; //LCOV_EXCL_LINE System Error
        }
 
        interface->dev->driver_detached[interface_number] = 1;
 
        return 0;
 
+//LCOV_EXCL_START System Error
 claim_failed:
        if (driver_detached)
                libusb_attach_kernel_driver(lusb_dev_handle,
                                            interface_number);
 out:
        return ret;
+//LCOV_EXCL_STOP
 }
 
 int usb_host_release_interface(usb_host_interface_h interface)
@@ -847,9 +861,9 @@ int usb_host_release_interface(usb_host_interface_h interface)
 
        ret = libusb_release_interface(lusb_dev_handle, interface_number);
        if (ret != 0) {
-               ret = translate_error(ret);
-               _E("Failed to release interface(%d)", ret);
-               goto out;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to release interface(%d)", ret); //LCOV_EXCL_LINE System Error
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        if (interface->dev->driver_detached[interface_number]) {
@@ -1024,9 +1038,9 @@ static int usb_host_device_get_string_descriptor_ascii(usb_host_device_h dev,
 
        ret = libusb_get_string_descriptor_ascii(dev->lusb_dev_handle, desc_index, data, *length);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to get descriptor(%d)", ret);
-               return ret;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to get descriptor(%d)", ret); //LCOV_EXCL_LINE System Error
+               return ret; //LCOV_EXCL_LINE System Error
        }
 
        *length = ret;
@@ -1422,16 +1436,16 @@ int usb_host_device_get_config(usb_host_device_h dev, int config_index, usb_host
        ret = libusb_get_config_descriptor(dev->lusb_dev,
                                           config_index, &lcfg_desc);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Failed to get configuration descriptor (%d)", ret);
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Failed to get configuration descriptor (%d)", ret); //LCOV_EXCL_LINE System Error
                goto out;
        }
 
        cfg = malloc(sizeof(*cfg));
        if (!cfg) {
-               _E("malloc() failed");
-               ret = USB_HOST_ERROR_OUT_OF_MEMORY;
-               goto free_lcfg_desc;
+               _E("malloc() failed"); //LCOV_EXCL_LINE System Error
+               ret = USB_HOST_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
+               goto free_lcfg_desc; //LCOV_EXCL_LINE System Error
        }
 
        ret = dump_config_desc(cfg, lcfg_desc, dev);
@@ -1470,9 +1484,9 @@ int usb_host_control_transfer(usb_host_device_h dev, uint8_t bmRequestType,
        ret = libusb_control_transfer(dev->lusb_dev_handle, bmRequestType, bRequest,
                                       wValue, wIndex, data, wLength, timeout);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Control transfer failed(%d)", ret);
-               return ret;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Control transfer failed(%d)", ret); //LCOV_EXCL_LINE System Error
+               return ret; //LCOV_EXCL_LINE System Error
        }
 
        *transfered = ret;
@@ -1499,9 +1513,9 @@ static int usb_host_bulk_transfer(usb_host_device_h dev, uint8_t endpoint,
        ret = libusb_bulk_transfer(dev->lusb_dev_handle, endpoint, data, length,
                                   transferred, timeout);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Bulk transfer failed (%d)", ret);
-               return ret;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Bulk transfer failed (%d)", ret); //LCOV_EXCL_LINE System Error
+               return ret; //LCOV_EXCL_LINE System Error
        }
 
        return USB_HOST_ERROR_NONE;
@@ -1526,9 +1540,9 @@ static int usb_host_interrupt_transfer(usb_host_device_h dev,
        ret = libusb_interrupt_transfer(dev->lusb_dev_handle, endpoint, data, length,
                                        transferred, timeout);
        if (ret < 0) {
-               ret = translate_error(ret);
-               _E("Interrupt transfer failed (%d)", ret);
-               return ret;
+               ret = translate_error(ret); //LCOV_EXCL_LINE System Error
+               _E("Interrupt transfer failed (%d)", ret); //LCOV_EXCL_LINE System Error
+               return ret; //LCOV_EXCL_LINE System Error
        }
 
        return USB_HOST_ERROR_NONE;