X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fstorage.c;h=01ec1fb91eb6f87b2a1e747801b34a0e5c31c3cb;hb=aa906855ab2fbffe34d7084e74557099f7d4bb23;hp=c5e7a6fe7dd953fa86fc821e3ddcad71a30e3f3e;hpb=e88e5c280cc7c0da5a13e3f2b501111e13d63206;p=platform%2Fcore%2Fsystem%2Flibstorage.git diff --git a/src/storage.c b/src/storage.c index c5e7a6f..01ec1fb 100644 --- a/src/storage.c +++ b/src/storage.c @@ -84,14 +84,16 @@ API int storage_foreach_device_supported(storage_device_supported_cb callback, v } if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NONE; + //LCOV_EXCL_STOP } ret_val = storage_ext_foreach_device_list(callback, user_data); if (ret_val < 0) { _E("Failed to iterate external devices (%d)", ret_val); //LCOV_EXCL_LINE - return STORAGE_ERROR_OPERATION_FAILED; + return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE } return STORAGE_ERROR_NONE; @@ -139,25 +141,31 @@ API int storage_get_root_directory(int storage_id, char **path) /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } ret_val = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint); if (ret_val < 0) { - _E("Failed to get root path of external storage(%d, %d", storage_id, ret_val); //LCOV_EXCL_LINE + _E("Failed to get root path of external storage(%d, %d", storage_id, ret_val); if (ret_val == -ENODEV || ret_val == -EINVAL) return STORAGE_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_START else if (ret_val == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; else return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } *path = strdup(root); if (!*path) { - _E("Failed to copy the root string : %d", errno); //LCOV_EXCL_LINE System Error + //LCOV_EXCL_START System error + _E("Failed to copy the root string : %d", errno); return STORAGE_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } return STORAGE_ERROR_NONE; @@ -220,8 +228,10 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p free(temp2); } else { if ((ret_val = snprintf(temp, PATH_MAX, "%s/%s", root, dir_path[type])) > PATH_MAX - 1) { + //LCOV_EXCL_START _E("Path is longer than buffer. Need %d size of buffer.", ret_val + 1); return STORAGE_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } } @@ -230,39 +240,47 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } if (type == STORAGE_DIRECTORY_SYSTEM_RINGTONES) { - _E("Not support directory : id(%d) type(%d)", storage_id, type); //LCOV_EXCL_LINE + _E("Not support directory : id(%d) type(%d)", storage_id, type); return STORAGE_ERROR_INVALID_PARAMETER; } ret_val = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint); if (ret_val < 0) { - _E("Failed to get root dir for external storage(id:%d, ret:%d)", storage_id, ret_val); //LCOV_EXCL_LINE + _E("Failed to get root dir for external storage(id:%d, ret:%d)", storage_id, ret_val); if (ret_val == -ENODEV || ret_val == -EINVAL) return STORAGE_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_START else if (ret_val == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; else return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } /* The operation is not decided */ if (extendedint) return STORAGE_ERROR_INVALID_PARAMETER; if ((ret_val = snprintf(temp, sizeof(temp), "%s/%s", root, dir_path[type])) > sizeof(temp) - 1) { + //LCOV_EXCL_START _E("Path is longer than buffer. Need %d size of buffer.", ret_val + 1); return STORAGE_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } out: *path = strdup(temp); if (!*path) { - _E("Failed to copy the directory(%d) string : %d", type, errno); //LCOV_EXCL_LINE + //LCOV_EXCL_START System error + _E("Failed to copy the directory(%d) string : %d", type, errno); return STORAGE_ERROR_OUT_OF_MEMORY; + //LCOV_EXCL_STOP } return STORAGE_ERROR_NONE; @@ -294,8 +312,10 @@ API int storage_get_type(int storage_id, storage_type_e *type) /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } ret_val = storage_ext_get_root(storage_id, root, sizeof(root), &extendedint); @@ -303,10 +323,12 @@ API int storage_get_type(int storage_id, storage_type_e *type) _E("Failed to get type of external storage"); if (ret_val == -ENODEV || ret_val == -EINVAL) return STORAGE_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_START else if (ret_val == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; else return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } if (extendedint) *type = STORAGE_TYPE_EXTENDED_INTERNAL; @@ -341,19 +363,23 @@ API int storage_get_state(int storage_id, storage_state_e *state) /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } ret_val = storage_ext_get_state(storage_id, &st); if (ret_val < 0) { - _E("Failed to get state (storage id(%d), ret_val(%d))", storage_id, ret_val); //LCOV_EXCL_LINE + _E("Failed to get state (storage id(%d), ret_val(%d))", storage_id, ret_val); if (ret_val == -ENODEV || ret_val == -EINVAL) return STORAGE_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_START else if (ret_val == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; else return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } *state = st; @@ -396,8 +422,10 @@ API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb ca /* For backward compatability */ if (storage_id == STORAGE_TYPE_EXTERNAL) { if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } if (!compat_cb_init) { @@ -425,8 +453,10 @@ API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb ca /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } info.id = storage_id; @@ -435,8 +465,10 @@ API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb ca ret = storage_ext_register_cb(STORAGE_CALLBACK_ID, &info); if (ret < 0) { - _E("Failed to register callback : id(%d)", storage_id); //LCOV_EXCL_LINE + //LCOV_EXCL_START + _E("Failed to register callback : id(%d)", storage_id); return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return STORAGE_ERROR_NONE; @@ -460,8 +492,10 @@ API int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb /* For backward compatability */ if (storage_id == STORAGE_TYPE_EXTERNAL) { if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } GList *elem_n; @@ -484,8 +518,10 @@ API int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } info.id = storage_id; @@ -493,8 +529,10 @@ API int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb ret_val = storage_ext_unregister_cb(STORAGE_CALLBACK_ID, &info); if (ret_val < 0) { - _E("Failed to unregister callback : id(%d)", storage_id); //LCOV_EXCL_LINE + //LCOV_EXCL_START + _E("Failed to unregister callback : id(%d)", storage_id); return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return STORAGE_ERROR_NONE; @@ -525,21 +563,25 @@ API int storage_get_total_space(int storage_id, unsigned long long *bytes) /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } ret_val = storage_ext_get_space(storage_id, &total, NULL); out: if (ret_val < 0) { - _E("Failed to get total memory : id(%d)", storage_id); //LCOV_EXCL_LINE + _E("Failed to get total memory : id(%d)", storage_id); if (ret_val == -ENODEV || ret_val == -EINVAL) return STORAGE_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_START else if (ret_val == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; else return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } *bytes = total; @@ -571,21 +613,25 @@ API int storage_get_available_space(int storage_id, unsigned long long *bytes) /* external storage */ if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } ret_val = storage_ext_get_space(storage_id, NULL, &avail); out: if (ret_val < 0) { - _E("Failed to get available memory : id(%d)", storage_id); //LCOV_EXCL_LINE + _E("Failed to get available memory : id(%d)", storage_id); if (ret_val == -ENODEV || ret_val == -EINVAL) return STORAGE_ERROR_INVALID_PARAMETER; + //LCOV_EXCL_START else if (ret_val == -ENOMEM) return STORAGE_ERROR_OUT_OF_MEMORY; else return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } *bytes = avail; @@ -613,8 +659,10 @@ API int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback, } if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _E("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } /* external storage */ @@ -624,8 +672,10 @@ API int storage_set_changed_cb(storage_type_e type, storage_changed_cb callback, ret_val = storage_ext_register_cb(STORAGE_CALLBACK_TYPE, &info); if (ret_val < 0) { - _E("Failed to register storage callback(ret:%d)", ret_val); //LCOV_EXCL_LINE + //LCOV_EXCL_START + _E("Failed to register storage callback(ret:%d)", ret_val); return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return STORAGE_ERROR_NONE; @@ -652,8 +702,10 @@ API int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callbac } if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _E("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } /* external storage */ @@ -662,8 +714,10 @@ API int storage_unset_changed_cb(storage_type_e type, storage_changed_cb callbac ret_val = storage_ext_unregister_cb(STORAGE_CALLBACK_TYPE, &info); if (ret_val < 0) { - _E("Failed to unregister storage callback(ret:%d)", ret_val); //LCOV_EXCL_LINE + //LCOV_EXCL_START + _E("Failed to unregister storage callback(ret:%d)", ret_val); return STORAGE_ERROR_OPERATION_FAILED; + //LCOV_EXCL_STOP } return STORAGE_ERROR_NONE; @@ -681,15 +735,19 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e ret = storage_get_type(storage_id, type); if (ret != STORAGE_ERROR_NONE) { + //LCOV_EXCL_START _E("Failed to get storage type: %d", ret); return ret; + //LCOV_EXCL_STOP } if (*type == STORAGE_TYPE_INTERNAL || *type == STORAGE_TYPE_EXTENDED_INTERNAL) return STORAGE_ERROR_INVALID_PARAMETER; if (!storage_ext_is_supported()) { + //LCOV_EXCL_START _D("Block module is not enabled"); return STORAGE_ERROR_NOT_SUPPORTED; + //LCOV_EXCL_STOP } ext_dev = calloc(1, sizeof(storage_ext_device)); @@ -707,8 +765,10 @@ API int storage_get_type_dev(int storage_id, storage_type_e *type, storage_dev_e ret = STORAGE_ERROR_INVALID_PARAMETER; goto out; } + //LCOV_EXCL_START ret = STORAGE_ERROR_OPERATION_FAILED; goto out; + //LCOV_EXCL_STOP } if (ext_dev->type == STORAGE_EXT_SCSI)