library: Use same terms in error mapping functions (in both directions) 43/279343/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Sat, 6 Aug 2022 13:15:13 +0000 (15:15 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Sat, 6 Aug 2022 13:26:23 +0000 (15:26 +0200)
Change-Id: I7f6e2a12a42848feabb49a34fd64633a747a7265

libsessiond/src/lib.c

index 01834cf..c994766 100644 (file)
@@ -202,8 +202,7 @@ static gboolean error_on_switch_bad_user_id(const char *user_id) {
        );
 }
 
-
-static int get_dbus_error_mapping_to_subsession_error(const char *dbus_error)
+static subsession_error_e errstr_to_errcode(const char *dbus_error)
 {
        size_t arr_size = sizeof(error_mappings) / sizeof(error_mappings[0]);
 
@@ -215,7 +214,7 @@ static int get_dbus_error_mapping_to_subsession_error(const char *dbus_error)
        return SUBSESSION_ERROR_IO_ERROR;
 }
 
-static subsession_error_e map_dbus_call_error_to_return_value(const GError *error)
+static subsession_error_e gerror_to_errcode(const GError *error)
 {
        if (!error)
                return SUBSESSION_ERROR_NONE;
@@ -230,7 +229,7 @@ static subsession_error_e map_dbus_call_error_to_return_value(const GError *erro
        }
 
        if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_DBUS_ERROR) {
-               return get_dbus_error_mapping_to_subsession_error(error->message);
+               return errstr_to_errcode(error->message);
        }
 
        return SUBSESSION_ERROR_IO_ERROR;
@@ -538,10 +537,8 @@ static int method_call_sync(gchar *method, GVariant *params, const GVariantType
 
        if (!retgv || call_sync_error) {
                LOGE("Error while calling DBus method %s: %s", method, g_dbus_error_get_remote_error(call_sync_error));
-               int err = map_dbus_call_error_to_return_value(call_sync_error);
-               log_if_error_(err)
                g_error_free(call_sync_error);
-               return err;
+               return gerror_to_errcode(call_sync_error);
        }
 
        if (out)
@@ -583,7 +580,7 @@ static void async_method_reply_handler(GObject *source_obj, GAsyncResult *res, g
        g_autoptr(GError) g_err = NULL;
        // ret's GVariant is unused, we are interested only if method call resulted in error or not
        g_autoptr(GVariant) ret = g_dbus_connection_call_finish(connection, res, &g_err);
-       subsession_error_e s_err = map_dbus_call_error_to_return_value(g_err);
+       subsession_error_e s_err = gerror_to_errcode(g_err);
        if (g_err)
                LOGI("DBus method call returned error: %s (SUBSESSION_ERROR code: %d)", g_dbus_error_get_remote_error(g_err), s_err);