Increase line coverage using LCOV_EXCL
[platform/core/system/libstorage.git] / src / storage-inhouse.c
index 45aba82..b6513af 100755 (executable)
@@ -176,12 +176,24 @@ API int storage_get_primary_sdcard(int *storage_id, char **path)
        if (!storage_ext_is_supported())
                return STORAGE_ERROR_NOT_SUPPORTED;
 
-       ret_dbus = gdbus_call_sync_with_reply(STORAGE_EXT_BUS_NAME,
+       dbus_handle_h dbus_handle = gdbus_get_connection(G_BUS_TYPE_SYSTEM, true);
+       if (dbus_handle == NULL) {
+               //LCOV_EXCL_START Dbus error
+               _E("Failed to get dbus connection");
+               return STORAGE_ERROR_OPERATION_FAILED;
+               //LCOV_EXCL_STOP
+       }
+
+       ret_dbus = gdbus_priv_call_sync_with_reply(dbus_handle,
+                       STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
                        STORAGE_EXT_IFACE_MANAGER,
                        "GetMmcPrimary",
                        NULL,
                        &reply);
+
+       gdbus_free_connection(dbus_handle);
+
        if (ret_dbus < 0) {
                //LCOV_EXCL_START System Error
                _E("Failed to get primary sdcard partition"); //LCOV_EXCL_LINE
@@ -196,8 +208,10 @@ API int storage_get_primary_sdcard(int *storage_id, char **path)
                        NULL, &reply_mount_point,
                        NULL, NULL,
                        NULL, &reply_id)) {
+               //LCOV_EXCL_START Dbus error
                g_variant_unref(reply);
                return STORAGE_ERROR_OPERATION_FAILED;
+               //LCOV_EXCL_STOP
        }
 
        g_variant_unref(reply);
@@ -210,7 +224,7 @@ API int storage_get_primary_sdcard(int *storage_id, char **path)
        *path = strdup(reply_mount_point);
        if (*path == NULL) {
                ret = STORAGE_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE System Error
-               goto out;
+               goto out; //LCOV_EXCL_LINE System Error
        }
 
        *storage_id = reply_id;
@@ -222,6 +236,7 @@ out:
        return ret;
 }
 
+//LCOV_EXCL_START Internal API
 API int storage_get_storage_level(const char *path, char **level)
 {
        int ret_level;
@@ -239,6 +254,7 @@ API int storage_get_storage_level(const char *path, char **level)
 
        return STORAGE_ERROR_NONE;
 }
+//LCOV_EXCL_STOP Internal API
 
 //LCOV_EXCL_START Not called callback
 static void mount_mmc_cb(GVariant *var, void *user_data, GError *err)
@@ -265,6 +281,7 @@ exit:
 }
 //LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Internal API
 API int storage_request_mount_mmc(struct mmc_contents *mmc_data)
 {
        void (*mount_cb)(GVariant *, void *, GError *) = NULL;
@@ -282,10 +299,8 @@ API int storage_request_mount_mmc(struct mmc_contents *mmc_data)
        ret_val = storage_get_primary_sdcard(&id, &path);
        if (ret_val != STORAGE_ERROR_NONE)
                return ret_val;
-//LCOV_EXCL_START System Error
        if (path)
                free(path);
-//LCOV_EXCL_STOP
 
        ret_val = gdbus_call_async_with_reply(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
@@ -305,6 +320,7 @@ API int storage_request_mount_mmc(struct mmc_contents *mmc_data)
 
        return STORAGE_ERROR_NONE;
 }
+//LCOV_EXCL_STOP Internal API
 
 //LCOV_EXCL_START Not called callback
 static void unmount_mmc_cb(GVariant *var, void *user_data, GError *err)
@@ -331,6 +347,7 @@ exit:
 }
 //LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Internal API
 API int storage_request_unmount_mmc(struct mmc_contents *mmc_data, int option)
 {
        void (*unmount_cb)(GVariant *, void *, GError *) = NULL;
@@ -351,10 +368,8 @@ API int storage_request_unmount_mmc(struct mmc_contents *mmc_data, int option)
        ret_val = storage_get_primary_sdcard(&id, &path);
        if (ret_val != STORAGE_ERROR_NONE)
                return ret_val;
-//LCOV_EXCL_START System Error
        if (path)
                free(path);
-//LCOV_EXCL_STOP
 
        ret_val = gdbus_call_async_with_reply(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
@@ -374,6 +389,7 @@ API int storage_request_unmount_mmc(struct mmc_contents *mmc_data, int option)
 
        return STORAGE_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
 //LCOV_EXCL_START Not called callback
 static void format_mmc_cb(GVariant *var, void *user_data, GError *err)
@@ -400,11 +416,14 @@ exit:
 }
 //LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Internal API
 API int storage_request_format_mmc(struct mmc_contents *mmc_data)
 {
        return storage_format_mmc(mmc_data, 1);
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Internal API
 API int storage_format_mmc(struct mmc_contents *mmc_data, int option)
 {
        void (*format_cb)(GVariant *, void *, GError *) = NULL;
@@ -425,10 +444,8 @@ API int storage_format_mmc(struct mmc_contents *mmc_data, int option)
        ret_val = storage_get_primary_sdcard(&id, &path);
        if (ret_val != STORAGE_ERROR_NONE)
                return ret_val;
-//LCOV_EXCL_START System Error
        if (path)
                free(path);
-//LCOV_EXCL_STOP
 
        ret_val = gdbus_call_async_with_reply(STORAGE_EXT_BUS_NAME,
                        STORAGE_EXT_PATH_MANAGER,
@@ -448,7 +465,9 @@ API int storage_format_mmc(struct mmc_contents *mmc_data, int option)
 
        return STORAGE_ERROR_NONE;
 }
+//LCOV_EXCL_STOP
 
+//LCOV_EXCL_START Internal API
 API int storage_is_mounted_opt_usr(storage_part_mount_e *mounted)
 {
        blkid_cache cache = NULL;
@@ -456,7 +475,7 @@ API int storage_is_mounted_opt_usr(storage_part_mount_e *mounted)
        blkid_dev dev;
        int ret_val;
        bool found = false;
-       char *user_label = is_container()? CONTAINER_USER_PARTITION: USER_PARTITION;
+       char *user_label = syscommon_is_container()? CONTAINER_USER_PARTITION: USER_PARTITION;
 
        if (!mounted)
                return STORAGE_ERROR_INVALID_PARAMETER;
@@ -525,3 +544,4 @@ API int storage_is_mounted_opt_usr(storage_part_mount_e *mounted)
 
        return STORAGE_ERROR_NONE;
 }
+//LCOV_EXCL_STOP