Skip to content

Commit

Permalink
Merge pull request timvideos#89 from mithro/g_error_free
Browse files Browse the repository at this point in the history
Fixing g_error usage in gstswitchcontroller.c
  • Loading branch information
mithro committed Jan 7, 2015
2 parents 7009b13 + 346a73e commit 4d73316
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions tools/gstswitchcontroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ gst_switch_controller_emit_ui_signal (GstSwitchController * controller,
signame, parameters, &error);

if (!res) {
g_assert (error != NULL);
ERROR ("emit: (%d) %s", num, error->message);
} else {
++num;
Expand Down Expand Up @@ -325,16 +326,16 @@ gst_switch_controller_on_connection_closed (GDBusConnection * connection,

if (error) {
WARN ("close: %s", error->message);
g_error_free (error);
}

g_object_unref (connection);
GST_SWITCH_CONTROLLER_LOCK_UIS (controller);
controller->uis = g_list_remove (controller->uis, connection);
GST_SWITCH_CONTROLLER_UNLOCK_UIS (controller);

INFO ("closed: %p, %d (%d uis)", connection, vanished,
g_list_length (controller->uis));

g_object_unref (connection);
}

static GVariant *gst_switch_controller_call_client (GstSwitchController *
Expand Down Expand Up @@ -413,17 +414,18 @@ gst_switch_controller_on_new_connection (GDBusServer * server,
NULL, /* user_data_free_func */
&error);

if (register_id <= 0 || error != NULL) {
if (error != NULL) {
ERROR ("failed to register controller: %s", error->message);
return TRUE;
g_error_free (error);
return FALSE;
} else if (register_id <= 0) {
ERROR ("register_id invalid (<= 0): %d", register_id);
return FALSE;
} else {
INFO ("registered: %d, %s, %s", register_id,
SWITCH_CONTROLLER_OBJECT_PATH, introspection_data->interfaces[0]->name);
}

/*
INFO ("registered: %d, %s, %s", register_id,
SWITCH_CONTROLLER_OBJECT_PATH,
introspection_data->interfaces[0]->name);
*/

g_signal_connect (connection, "closed",
G_CALLBACK (gst_switch_controller_on_connection_closed), controller);

Expand Down Expand Up @@ -474,12 +476,13 @@ gst_switch_controller_init (GstSwitchController * controller)
auth_observer = g_dbus_auth_observer_new ();
controller->bus_server = g_dbus_server_new_sync (SWITCH_CONTROLLER_ADDRESS, flags, guid, auth_observer, NULL, /* GCancellable */
&error);
if (error != NULL) {
g_error ("failed to register controller: %s", error->message);
}
g_assert (controller->bus_server != NULL);

g_free (guid);

if (controller->bus_server == NULL)
goto error_new_server;

INFO ("Controller is listening at: %s",
g_dbus_server_get_client_address (controller->bus_server));

Expand All @@ -496,14 +499,6 @@ gst_switch_controller_init (GstSwitchController * controller)

// TODO: singleton object
return;

/* Errors Handling */
error_new_server:
{
if (error)
ERROR ("%s", error->message);
return;
}
}

/**
Expand Down Expand Up @@ -580,20 +575,16 @@ gst_switch_controller_call_client (GstSwitchController * controller,
NULL /* TODO: cancellable */ ,
&error);

if (error != NULL)
goto error_call_sync;

return value;

/* ERRORS */
error_call_sync:
{
if (error != NULL) {
ERROR ("%s (%s)", error->message, method_name);
g_error_free (error);
if (value)
g_variant_unref (value);
return NULL;
}
g_assert (value != NULL);

return value;
}

/**
Expand Down

0 comments on commit 4d73316

Please sign in to comment.