Revert "block: dbus: modified to reply error type message if failed" 38/207638/2 accepted/tizen/unified/20190611.050130 submit/tizen/20190610.102436
authorHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 10 Jun 2019 10:17:36 +0000 (10:17 +0000)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Mon, 10 Jun 2019 10:21:42 +0000 (10:21 +0000)
This reverts commit bdbefcfd9dc654860f7988d69753b5159e1bfb86.

Change-Id: I44d2ed00df58ab2871a1f5c36870c44e3d2e0c30

apps/extended-sd/src/es-portable-storage-page.c
src/auto-test/block.c
src/block/block.c

index e24eed0..5826f58 100644 (file)
@@ -119,11 +119,6 @@ mapper_device_cb(int mapper_id, storage_dev_e dev, storage_state_e state,
        }
 
        g_variant_get(output, "(a(issssssisibii))", &iter);
-       if (g_variant_iter_n_children(iter) == 0) {
-               DMSG("Failed to get DeviceList from gvariant.");
-               g_variant_iter_free(iter);
-               return;
-       }
 
        while (g_variant_iter_loop(iter, "(issssssisibii)",
                                NULL, NULL, NULL,
@@ -142,8 +137,6 @@ mapper_device_cb(int mapper_id, storage_dev_e dev, storage_state_e state,
                break;
        }
 
-       g_variant_iter_free(iter);
-
        ret = dbus_handle_method_async_with_reply_var(STORAGED_BUS_NAME,
                        STORAGED_PATH_BLOCK_MANAGER,
                        STORAGED_INTERFACE_BLOCK_MANAGER,
index a9b8e95..7098387 100644 (file)
@@ -137,17 +137,11 @@ static bool block_getdevicelist(char *type)
                g_variant_new("(s)", type));
 
        if (!msg) {
-               _E("Failed to call dbus method(%s)", METHOD_BLOCK_GETMMCPRIMARY);
+               _E("Failed to call dbus method(%s): no reply", METHOD_BLOCK_GETMMCPRIMARY);
                return ret;
        }
 
        g_variant_get(msg, "(a(issssssisibii))", &iter);
-       if (g_variant_iter_n_children(iter) == 0) {
-               _E("Failed to get DeviceList from gvariant.");
-               g_variant_iter_free(iter);
-               return ret;
-       }
-
        while (g_variant_iter_loop(iter, "(issssssisibii)",
                        NULL, NULL, NULL, NULL, NULL, NULL,
                        NULL, NULL, NULL, NULL, NULL, NULL, &val)) {
@@ -155,8 +149,6 @@ static bool block_getdevicelist(char *type)
                ret = TRUE;
        }
 
-       g_variant_iter_free(iter);
-
        _I("Success. (%s): %d", METHOD_BLOCK_GETDEVICELIST, ret);
        return ret;
 }
@@ -176,17 +168,11 @@ static bool block_getdevicelist2(char *type)
                g_variant_new("(s)", type));
 
        if (!msg) {
-               _E("Failed to call dbus method(%s)", METHOD_BLOCK_GETMMCPRIMARY);
+               _E("Failed to call dbus method(%s): no reply", METHOD_BLOCK_GETMMCPRIMARY);
                return ret;
        }
 
        g_variant_get(msg, "(a(issssssisibi))", &iter);
-       if (g_variant_iter_n_children(iter) == 0) {
-               _E("Failed to get DeviceList2 from gvariant.");
-               g_variant_iter_free(iter);
-               return ret;
-       }
-
        while (g_variant_iter_loop(iter, "(issssssisibi)",
                        NULL, &val, NULL, NULL, NULL, NULL,
                        NULL, NULL, NULL, NULL, NULL, NULL)) {
@@ -194,8 +180,6 @@ static bool block_getdevicelist2(char *type)
                ret = TRUE;
        }
 
-       g_variant_iter_free(iter);
-
        _I("Success. %s: %d", METHOD_BLOCK_GETDEVICELIST2, ret);
        return ret;
 }
index f179834..8d8e992 100644 (file)
@@ -3269,14 +3269,12 @@ static GVariant *request_get_device_list(GDBusConnection *conn,
        char *type = NULL;
        enum block_device_type block_type;
        int i;
-       int item_cnt = 0;
        GVariantBuilder *builder = NULL;
-       const char *error = NULL;
 
        g_variant_get(param, "(s)", &type);
+
        if (!type) {
                _E("Delivered type is NULL.");
-               error = "Delivered type is NULL";
                goto out;
        }
 
@@ -3285,12 +3283,10 @@ static GVariant *request_get_device_list(GDBusConnection *conn,
        block_type = get_bdev_type_from_type_string(type);
        if (block_type == BLOCK_UNKNOWN_DEV) {
                _E("Invalid type (%s) is requested.", type);
-               error = "Invalid type is requested";
                goto out;
        }
 
        builder = g_variant_builder_new(G_VARIANT_TYPE("a(issssssisibii)"));
-       item_cnt = 0;
 
        for (i = 0; i < THREAD_MAX; i++) {
                pthread_mutex_lock(&(th_manager[i].mutex));
@@ -3319,29 +3315,16 @@ static GVariant *request_get_device_list(GDBusConnection *conn,
                                        data->primary,
                                        data->flags,
                                        data->id);
-                       ++item_cnt;
                }
                pthread_mutex_unlock(&(th_manager[i].mutex));
        }
-       /* if nothing is added, then gvariant(empty body) is generated */
-       if (item_cnt == 0) {
-               _E("Not found matched device(%s).", type);
-               error = "Not found matched device";
-               goto out;
-       }
-
        reply = g_variant_new("(a(issssssisibii))", builder);
+       g_variant_builder_unref(builder);
 
 out:
-       if (builder)
-               g_variant_builder_unref(builder);
-
        g_free(type);
-
        if (!reply)
-               g_dbus_method_invocation_return_error(invocation,
-                               G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
-                               "%s", error);
+               reply = dbus_handle_new_g_variant_tuple();
        return reply;
 }
 
@@ -3357,14 +3340,11 @@ static GVariant *request_get_device_list_2(GDBusConnection *conn,
        char *type = NULL;
        enum block_device_type block_type;
        int i;
-       int item_cnt;
        GVariantBuilder *builder = NULL;
-       const char *error = NULL;
 
        g_variant_get(param, "(s)", &type);
        if (!type) {
                _E("Delivered type is NULL.");
-               error = "Delivered type is NULL";
                goto out;
        }
 
@@ -3373,12 +3353,10 @@ static GVariant *request_get_device_list_2(GDBusConnection *conn,
        block_type = get_bdev_type_from_type_string(type);
        if (block_type == BLOCK_UNKNOWN_DEV) {
                _E("Invalid type (%s) is requested.", type);
-               error = "Invalid type is requested";
                goto out;
        }
 
        builder = g_variant_builder_new(G_VARIANT_TYPE("a(issssssisibi)"));
-       item_cnt = 0;
 
        for (i = 0; i < THREAD_MAX; i++) {
                pthread_mutex_lock(&(th_manager[i].mutex));
@@ -3406,29 +3384,14 @@ static GVariant *request_get_device_list_2(GDBusConnection *conn,
                                        data->state,
                                        data->primary,
                                        data->flags);
-                       ++item_cnt;
                }
                pthread_mutex_unlock(&(th_manager[i].mutex));
        }
-       /* if nothing is added, then gvariant(empty body) is generated */
-       if (item_cnt == 0) {
-               _E("Not found matched device(%s).", type);
-               error = "Not found matched device";
-               goto out;
-       }
-
        reply = g_variant_new("(a(issssssisibi))", builder);
+       g_variant_builder_unref(builder);
 
 out:
-       if (builder)
-               g_variant_builder_unref(builder);
-
        g_free(type);
-
-       if (!reply)
-               g_dbus_method_invocation_return_error(invocation,
-                               G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
-                               "%s", error);
        return reply;
 }