Increase line coverage using LCOV_EXCL
[platform/core/system/libstorage.git] / src / storage-external.c
index 3ffcf4a..65719d4 100755 (executable)
@@ -95,13 +95,13 @@ int storage_ext_get_space(int storage_id,
        ret = storage_ext_get_device_info(storage_id, dev);
        if (ret < 0) {
                _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
-               goto out;
+               goto out; //LCOV_EXCL_LINE
        }
 
        ret = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, &state);
        if (ret < 0) {
                _E("Failed to get state of storage (id:%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
-               goto out;
+               goto out; //LCOV_EXCL_LINE
        }
 
        if (state >= STORAGE_STATE_MOUNTED) {
@@ -112,7 +112,7 @@ int storage_ext_get_space(int storage_id,
 #endif
                if (ret < 0) {
                        _E("Failed to get external memory size of (%s)(ret:%d)", dev->mount_point, ret); //LCOV_EXCL_LINE
-                       goto out;
+                       goto out; //LCOV_EXCL_LINE
                }
 
                t = (unsigned long long)s.f_frsize*s.f_blocks;
@@ -144,14 +144,14 @@ int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *
        ret_val = storage_ext_get_list(&list);
        if (ret_val < 0) {
                _E("Failed to get external storage list from deviced (%d)", errno); //LCOV_EXCL_LINE
-               return ret_val;
+               return ret_val; //LCOV_EXCL_LINE
        }
 
        SYS_G_LIST_FOREACH(list, elem, dev) {
                ret_val = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, &state);
                if (ret_val < 0) {
                        _E("Failed to get storage state (devnode:%s, ret_val:%d)", dev->devnode, ret_val); //LCOV_EXCL_LINE
-                       continue;
+                       continue; //LCOV_EXCL_LINE
                }
 
                if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL)
@@ -326,7 +326,7 @@ int storage_ext_register_cb(enum storage_cb_type type, struct storage_cb_info *i
        /* add device changed callback to list (local) */
        cb_info = malloc(sizeof(struct storage_cb_info));
        if (!cb_info)
-               return -errno;
+               return -errno; //LCOV_EXCL_LINE
 
        memcpy(cb_info, info, sizeof(struct storage_cb_info));
        SYS_G_LIST_APPEND(cb_list[type], cb_info);
@@ -356,8 +356,10 @@ int storage_ext_unregister_cb(enum storage_cb_type type, struct storage_cb_info
        }
 
        if (!check_if_callback_exist(type, info, &cb_info)) {
+               //LCOV_EXCL_START Callbacked is not registered case
                _E("The callback is not registered");
                return 0;
+               //LCOV_EXCL_STOP
        }
 
        /* remove device callback from list (local) */
@@ -399,33 +401,41 @@ int storage_ext_get_root(int storage_id, char *path, size_t len, bool *extendedi
        if (access(file_name, R_OK) == 0) {
                fp = fopen(file_name, "r");
                if (!fp) {
-                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+                       //LCOV_EXCL_START File operation error
+                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
                        ret = -ENODEV;
                        goto out;
+                       //LCOV_EXCL_STOP
                }
 
                tmp = fgets(path, len, fp);
                fclose(fp);
                if (!tmp) {
+                       //LCOV_EXCL_START File operation error
                        ret = -ENODEV;
                        _D("Failed to get path");
                        goto out;
+                       //LCOV_EXCL_STOP
                }
                *extendedinternal = false;
        } else if (access(file_name2, R_OK) == 0) {
                fp = fopen(file_name2, "r");
                if (!fp) {
-                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+                       //LCOV_EXCL_START File operation error
+                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
                        ret = -ENODEV;
                        goto out;
+                       //LCOV_EXCL_STOP
                }
 
                tmp = fgets(path, len, fp);
                fclose(fp);
                if (!tmp) {
+                       //LCOV_EXCL_START File operation error
                        ret = -ENODEV;
                        _D("Failed to get path");
                        goto out;
+                       //LCOV_EXCL_STOP
                }
                *extendedinternal = true;
        } else {
@@ -439,9 +449,11 @@ int storage_ext_get_root(int storage_id, char *path, size_t len, bool *extendedi
 
                ret = storage_ext_get_device_info(storage_id, dev);
                if (ret < 0) {
-                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+                       //LCOV_EXCL_START
+                       _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
                        storage_ext_release_device(&dev);
                        goto out;
+                       //LCOV_EXCL_STOP
                }
 
                snprintf(path, len, "%s", dev->mount_point);
@@ -479,8 +491,10 @@ int storage_ext_get_state(int storage_id, storage_state_e *state)
 
        ret = storage_ext_get_device_info(storage_id, dev);
        if (ret < 0) {
-               _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret); //LCOV_EXCL_LINE
+               //LCOV_EXCL_START
+               _E("Cannot get the storage with id (%d, ret:%d)", storage_id, ret);
                goto out;
+               //LCOV_EXCL_STOP
        }
 
        ret = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, state);
@@ -500,8 +514,10 @@ int storage_ext_get_primary_mmc_path(char *path, size_t len)
 
        ret = storage_ext_get_list(&list);
        if (ret < 0) {
-               _E("Failed to get external storage list from deviced (%d)", errno); //LCOV_EXCL_LINE
+               //LCOV_EXCL_START
+               _E("Failed to get external storage list from deviced (%d)", errno);
                return ret;
+               //LCOV_EXCL_STOP
        }
 
        SYS_G_LIST_FOREACH(list, elem, dev) {