Increase line coverage using LCOV_EXCL
[platform/core/system/libstorage.git] / src / storage-external.c
index e260ebc..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;
@@ -132,7 +132,7 @@ out:
 
 int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *user_data)
 {
-       int ret;
+       int ret_val;
        bool ret_cb;
        GList *list = NULL, *elem;
        storage_ext_device *dev;
@@ -141,17 +141,17 @@ int storage_ext_foreach_device_list(storage_device_supported_cb callback, void *
        if (!callback)
                return -EINVAL;
 
-       ret = storage_ext_get_list(&list);
-       if (ret < 0) {
+       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;
+               return ret_val; //LCOV_EXCL_LINE
        }
 
        SYS_G_LIST_FOREACH(list, elem, dev) {
-               ret = storage_ext_get_dev_state(dev, STORAGE_EXT_CHANGED, &state);
-               if (ret < 0) {
-                       _E("Failed to get storage state (devnode:%s, ret:%d)", dev->devnode, ret); //LCOV_EXCL_LINE
-                       continue;
+               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; //LCOV_EXCL_LINE
                }
 
                if (dev->type == STORAGE_EXT_MMC_EXTENDED_INTERNAL)
@@ -203,7 +203,7 @@ static int storage_ext_type_changed(storage_ext_device *dev, enum storage_ext_st
        struct storage_cb_info *cb_info;
        GList *elem;
        storage_state_e state;
-       int ret;
+       int ret_val;
        storage_dev_e strdev;
        storage_type_e storage_type;
        const char *fstype, *fsuuid, *mountpath;
@@ -214,10 +214,10 @@ static int storage_ext_type_changed(storage_ext_device *dev, enum storage_ext_st
        if (type != STORAGE_CALLBACK_TYPE)
                return -EINVAL;
 
-       ret = storage_ext_get_dev_state(dev, blk_state, &state);
-       if (ret < 0) {
-               _E("Failed to get storage state (devnode:%s, ret:%d)", dev->devnode, ret);
-               return ret;
+       ret_val = storage_ext_get_dev_state(dev, blk_state, &state);
+       if (ret_val < 0) {
+               _E("Failed to get storage state (devnode:%s, ret_val:%d)", dev->devnode, ret_val);
+               return ret_val;
        }
 
        if (dev->type == STORAGE_EXT_SCSI) {
@@ -293,7 +293,7 @@ out:
 int storage_ext_register_cb(enum storage_cb_type type, struct storage_cb_info *info)
 {
        struct storage_cb_info *cb_info;
-       int n, ret;
+       int n, ret_val;
        storage_ext_changed_cb callback;
 
        if (!info)
@@ -313,8 +313,8 @@ int storage_ext_register_cb(enum storage_cb_type type, struct storage_cb_info *i
 
        n = SYS_G_LIST_LENGTH(cb_list[type]);
        if (n == 0) {
-               ret = storage_ext_register_device_change(callback, (void *)type);
-               if (ret < 0)
+               ret_val = storage_ext_register_device_change(callback, (void *)type);
+               if (ret_val < 0)
                        return -EPERM;
        }
 
@@ -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) {