From 999645b53cd76fefa54e24a73c4239183ecbb81f Mon Sep 17 00:00:00 2001 From: "taemin.yeom" Date: Tue, 9 Mar 2021 15:26:55 +0900 Subject: [PATCH] Apply libsyscommon gdbus api improvement on error handling Change-Id: I50e592ff81431ff8580c9c153d865e3f0144c616 Signed-off-by: taemin.yeom --- src/storage-external-dbus.c | 38 +++++++++++++++++++++++--------------- src/storage-inhouse.c | 7 ++++--- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/storage-external-dbus.c b/src/storage-external-dbus.c index a6e83c7..ee3016e 100755 --- a/src/storage-external-dbus.c +++ b/src/storage-external-dbus.c @@ -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; } diff --git a/src/storage-inhouse.c b/src/storage-inhouse.c index 83dd93e..fddb656 100755 --- a/src/storage-inhouse.c +++ b/src/storage-inhouse.c @@ -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 -- 2.7.4