library: Automatically free GError* in method_call_sync() 44/279344/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Sat, 6 Aug 2022 13:20:33 +0000 (15:20 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Sat, 6 Aug 2022 13:26:45 +0000 (15:26 +0200)
Change-Id: Iddb19ec2556106e2ac1f5052dd4512dbff43194d

libsessiond/src/lib.c

index c994766..08894ae 100644 (file)
@@ -523,7 +523,7 @@ static int method_call_sync(gchar *method, GVariant *params, const GVariantType
 
        MAKE_SURE_CONNECTION_IS_NOT_NULL();
 
-       GError *call_sync_error = NULL;
+       g_autoptr(GError) g_err = NULL;
        GVariant *retgv = g_dbus_connection_call_sync(
                                conn_config_,
                                method,
@@ -532,13 +532,12 @@ static int method_call_sync(gchar *method, GVariant *params, const GVariantType
                                G_DBUS_CALL_FLAGS_NONE,
                                libsessiond_default_timeout,
                                NULL,
-                               &call_sync_error
+                               &g_err
                          );
 
-       if (!retgv || call_sync_error) {
-               LOGE("Error while calling DBus method %s: %s", method, g_dbus_error_get_remote_error(call_sync_error));
-               g_error_free(call_sync_error);
-               return gerror_to_errcode(call_sync_error);
+       if (!retgv || g_err) {
+               LOGE("Error while calling DBus method %s: %s", method, g_dbus_error_get_remote_error(g_err));
+               return gerror_to_errcode(g_err);
        }
 
        if (out)