Apply libsyscommon gdbus api improvement on error handling 44/254744/1 accepted/tizen/unified/20210310.144937 submit/tizen/20210309.090957
authortaemin.yeom <taemin.yeom@samsung.com>
Tue, 9 Mar 2021 06:26:55 +0000 (15:26 +0900)
committertaemin.yeom <taemin.yeom@samsung.com>
Tue, 9 Mar 2021 06:26:55 +0000 (15:26 +0900)
Change-Id: I50e592ff81431ff8580c9c153d865e3f0144c616
Signed-off-by: taemin.yeom <taemin.yeom@samsung.com>
src/storage-external-dbus.c
src/storage-inhouse.c

index a6e83c7..ee3016e 100755 (executable)
@@ -104,12 +104,13 @@ int storage_ext_get_list(GList **list)
        if (!list)
                return -EINVAL;
 
-       result = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
+       ret = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
                        STORAGE_EXT_IFACE_MANAGER,
                        STORAGE_EXT_GET_LIST,
-                       g_variant_new("(s)", "all"));
-       if (!result) {
+                       g_variant_new("(s)", "all"),
+                       &result);
+       if (ret < 0) {
                _E("Failed to get storage_ext device info"); //LCOV_EXCL_LINE
                return -EIO;
        }
@@ -165,18 +166,20 @@ out:
 int storage_ext_get_statvfs(char *path, struct statvfs_32 *buf)
 {
        GVariant *result;
+       int ret;
        guint64 bsize, frsize, blocks, bfree, bavail, files, ffree, favail, fsid, flag, namemax;
 
        assert(buf);
 
        memset(buf, 0, sizeof(struct statvfs_32));
 
-       result = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
+       ret = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_STORAGE,
                        STORAGE_EXT_IFACE_STORAGE,
                        STORAGE_EXT_GET_STATVFS,
-                       g_variant_new("(s)", path));
-       if (!result) {
+                       g_variant_new("(s)", path),
+                       &result);
+       if (ret < 0) {
                _E("Failed to get storage_ext device info"); //LCOV_EXCL_LINE
                return -EIO;
        }
@@ -211,17 +214,19 @@ int storage_ext_get_statvfs(char *path, struct statvfs_32 *buf)
 int storage_ext_get_statvfs_size64(char *path, struct statvfs *buf)
 {
        GVariant *result;
+       int ret;
 
        assert(buf);
 
        memset(buf, 0, sizeof(struct statvfs));
 
-       result = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
+       ret = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_STORAGE,
                        STORAGE_EXT_IFACE_STORAGE,
                        STORAGE_EXT_GET_STATVFS,
-                       g_variant_new("(s)", path));
-       if (!result) {
+                       g_variant_new("(s)", path),
+                       &result);
+       if (ret < 0) {
                _E("Failed to get storage_ext device info"); //LCOV_EXCL_LINE
                return -EIO;
        }
@@ -245,6 +250,7 @@ int storage_ext_get_statvfs_size64(char *path, struct statvfs *buf)
 int storage_ext_get_storage_level(const char *path, char **level)
 {
        GVariant *result;
+       int ret;
        char *tmp;
        enum tzplatform_variable id;
 
@@ -259,12 +265,13 @@ int storage_ext_get_storage_level(const char *path, char **level)
                return -EINVAL;
        }
 
-       result = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
+       ret = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_STORAGE,
                        STORAGE_EXT_IFACE_STORAGE,
                        STORAGE_EXT_GET_STORAGE_LEVEL,
-                       g_variant_new("(i)", id));
-       if (!result) {
+                       g_variant_new("(i)", id),
+                       &result);
+       if (ret < 0) {
                _E("Failed to get %d level", id);
                return -EIO;
        }
@@ -448,12 +455,13 @@ int storage_ext_get_device_info(int storage_id, storage_ext_device *info)
        GVariant *result;
        int ret;
 
-       result = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
+       ret = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
                        STORAGE_EXT_IFACE_MANAGER,
                        "GetDeviceInfo",
-                       g_variant_new("(i)", storage_id));
-       if (!result) {
+                       g_variant_new("(i)", storage_id),
+                       &result);
+       if (ret < 0) {
                _E("There is no storage with the storage id (%d)", storage_id); //LCOV_EXCL_LINE
                return -ENODEV;
        }
index 83dd93e..fddb656 100755 (executable)
@@ -174,12 +174,13 @@ API int storage_get_primary_sdcard(int *storage_id, char **path)
        if (!storage_ext_is_supported())
                return STORAGE_ERROR_NOT_SUPPORTED;
 
-       result = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
+       ret = dbus_handle_method_sync_with_reply_var(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
                        STORAGE_EXT_IFACE_MANAGER,
                        "GetMmcPrimary",
-                       NULL);
-       if (!result) {
+                       NULL,
+                       &result);
+       if (ret < 0) {
                //LCOV_EXCL_START System Error
                _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE
                return STORAGE_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE