storage id: return NOT_SUPPORTED if storage id is invalid 19/68919/1
authorTaeyoung Kim <ty317.kim@samsung.com>
Tue, 10 May 2016 10:36:12 +0000 (19:36 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Tue, 10 May 2016 10:36:12 +0000 (19:36 +0900)
- When storage id is invalid, the apis should return
  NOT_SUPPORTED. This is for backward compatibility.

Change-Id: I5c54f0675072979dfc42242e5ce9b8efc438190d
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
src/storage-external.c
src/storage.c

index d6d6bcacd42c553003e08baa72c6f7358073b9a1..bd9a8e113f5a28790aae196b457b1779b388c4dd 100755 (executable)
@@ -70,7 +70,7 @@ int storage_ext_get_space(int storage_id,
        storage_ext_device *dev;
 
        if (storage_id < 0)
-               return -EINVAL;
+               return -ENOTSUP;
 
        dev = calloc(1, sizeof(storage_ext_device));
        if (!dev) {
@@ -254,7 +254,10 @@ int storage_ext_get_root(int storage_id, char *path, size_t len)
        storage_ext_device *dev;
        int ret;
 
-       if (storage_id < 0 || !path)
+       if (storage_id < 0)
+               return -ENOTSUP;
+
+       if (!path)
                return -EINVAL;
 
        dev = calloc(1, sizeof(storage_ext_device));
@@ -282,7 +285,10 @@ int storage_ext_get_state(int storage_id, storage_state_e *state)
        storage_ext_device *dev;
        int ret;
 
-       if (storage_id < 0 || !state)
+       if (storage_id < 0)
+               return -ENOTSUP;
+
+       if (!state)
                return -EINVAL;
 
        dev = calloc(1, sizeof(storage_ext_device));
index c71af5cf8832e9493fca11f37a2338f46d7e4da3..b98fded47d3e2f1db16c5732c5b8359d8925cd68 100644 (file)
@@ -85,7 +85,10 @@ API int storage_get_root_directory(int storage_id, char **path)
        char root[PATH_MAX];
        int ret;
 
-       if (!path || storage_id < 0) {
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
+       if (!path) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
@@ -128,7 +131,10 @@ API int storage_get_directory(int storage_id, storage_directory_e type, char **p
        dd_list *elem;
        bool found;
 
-       if (!path || storage_id < 0) {
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
+       if (!path) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
@@ -195,7 +201,10 @@ API int storage_get_type(int storage_id, storage_type_e *type)
        const struct storage_ops *st;
        dd_list *elem;
 
-       if (!type || storage_id < 0) {
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
+       if (!type) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
@@ -221,7 +230,10 @@ API int storage_get_state(int storage_id, storage_state_e *state)
        dd_list *elem;
        int ret;
 
-       if (!state || storage_id < 0) {
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
+       if (!state) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
@@ -252,6 +264,9 @@ API int storage_set_state_changed_cb(int storage_id, storage_state_changed_cb ca
        int ret;
        dd_list *elem;
 
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
        if (!callback) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
@@ -283,6 +298,9 @@ API int storage_unset_state_changed_cb(int storage_id, storage_state_changed_cb
        int ret;
        dd_list *elem;
 
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
        if (!callback) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
@@ -313,7 +331,10 @@ API int storage_get_total_space(int storage_id, unsigned long long *bytes)
        int ret;
        dd_list *elem;
 
-       if (!bytes || storage_id < 0) {
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
+       if (!bytes) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
        }
@@ -332,6 +353,8 @@ API int storage_get_total_space(int storage_id, unsigned long long *bytes)
 out:
        if (ret < 0) {
                _E("Failed to get total memory : id(%d)", storage_id);
+               if (ret == -ENOTSUP)
+                       return STORAGE_ERROR_NOT_SUPPORTED;
                return STORAGE_ERROR_OPERATION_FAILED;
        }
 
@@ -346,6 +369,9 @@ API int storage_get_available_space(int storage_id, unsigned long long *bytes)
        int ret;
        dd_list *elem;
 
+       if (storage_id < 0)
+               return STORAGE_ERROR_NOT_SUPPORTED;
+
        if (!bytes) {
                _E("Invalid parameger");
                return STORAGE_ERROR_INVALID_PARAMETER;
@@ -365,6 +391,8 @@ API int storage_get_available_space(int storage_id, unsigned long long *bytes)
 out:
        if (ret < 0) {
                _E("Failed to get available memory : id(%d)", storage_id);
+               if (ret == -ENOTSUP)
+                       return STORAGE_ERROR_NOT_SUPPORTED;
                return STORAGE_ERROR_OPERATION_FAILED;
        }