[at-spi2-core] Code clean-ups
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Code clean-ups
- Date: Wed, 18 Jul 2012 17:33:10 +0000 (UTC)
commit b2873b58e6d2702d3db2477ac2f151098e0cde70
Author: Mike Gorse <mgorse suse com>
Date: Wed Jul 18 12:29:24 2012 -0500
Code clean-ups
There isn't really any point in checking for GLib functions returning NULL
due to lack of memory, since they just abort instead.
atspi/atspi-collection.c | 5 +----
atspi/atspi-device-listener.c | 12 ++----------
atspi/atspi-event-listener.c | 23 ++++-------------------
atspi/atspi-misc.c | 8 ++------
atspi/atspi-relation.c | 5 +----
atspi/atspi-stateset.c | 6 +-----
6 files changed, 11 insertions(+), 48 deletions(-)
---
diff --git a/atspi/atspi-collection.c b/atspi/atspi-collection.c
index b401d10..138d658 100644
--- a/atspi/atspi-collection.c
+++ b/atspi/atspi-collection.c
@@ -91,11 +91,8 @@ return_accessibles (DBusMessage *message)
while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
{
AtspiAccessible *accessible;
- GArray *new_array;
accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
- new_array = g_array_append_val (ret, accessible);
- if (new_array)
- ret = new_array;
+ ret = g_array_append_val (ret, accessible);
/* Iter was moved already, so no need to call dbus_message_iter_next */
}
dbus_message_unref (message);
diff --git a/atspi/atspi-device-listener.c b/atspi/atspi-device-listener.c
index 58a6d6a..9d2796e 100644
--- a/atspi/atspi-device-listener.c
+++ b/atspi/atspi-device-listener.c
@@ -164,14 +164,12 @@ atspi_device_event_dispatch (AtspiDeviceListener *listener,
static void
atspi_device_listener_init (AtspiDeviceListener *listener)
{
- GList *new_list;
do
{
listener->id = listener_id++;
} while (!id_is_free (listener->id));
- new_list = g_list_append (device_listeners, listener);
- if (new_list) device_listeners = new_list;
+ device_listeners = g_list_append (device_listeners, listener);
}
static void
@@ -278,13 +276,7 @@ atspi_device_listener_add_callback (AtspiDeviceListener *listener,
new_handler = device_event_handler_new (callback,
callback_destroyed, user_data);
- if (new_handler)
- {
- GList *new_list;
- new_list = g_list_prepend (listener->callbacks, new_handler);
- if (new_list)
- listener->callbacks = new_list;
- }
+ listener->callbacks = g_list_prepend (listener->callbacks, new_handler);
}
/**
diff --git a/atspi/atspi-event-listener.c b/atspi/atspi-event-listener.c
index 781488e..2b0798e 100644
--- a/atspi/atspi-event-listener.c
+++ b/atspi/atspi-event-listener.c
@@ -209,9 +209,9 @@ cache_process_children_changed (AtspiEvent *event)
{
if (g_list_find (event->source->children, child))
return;
- GList *new_list = g_list_insert (event->source->children, g_object_ref (child), event->detail1);
- if (new_list)
- event->source->children = new_list;
+ event->source->children = g_list_insert (event->source->children,
+ g_object_ref (child),
+ event->detail1);
}
else if (g_list_find (event->source->children, child))
{
@@ -345,12 +345,10 @@ convert_event_type_to_dbus (const char *eventType, char **categoryp, char **name
if (tmp == NULL) return FALSE;
category = strtok_r (tmp, ":", &saveptr);
if (category) category = g_strdup (category);
- if (!category) goto oom;
name = strtok_r (NULL, ":", &saveptr);
if (name)
{
name = g_strdup (name);
- if (!name) goto oom;
detail = strtok_r (NULL, ":", &saveptr);
if (detail) detail = g_strdup (detail);
}
@@ -384,12 +382,6 @@ convert_event_type_to_dbus (const char *eventType, char **categoryp, char **name
else if (detail) g_free (detail);
g_free (tmp);
return TRUE;
-oom:
- if (tmp) g_free (tmp);
- if (category) g_free (category);
- if (name) g_free (name);
- if (detail) g_free (detail);
- return FALSE;
}
static void
@@ -531,7 +523,6 @@ atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
{
EventListenerEntry *e;
DBusError d_error;
- GList *new_list;
DBusMessage *message, *reply;
GPtrArray *matchrule_array;
gint i;
@@ -558,13 +549,7 @@ atspi_event_listener_register_from_callback (AtspiEventListenerCB callback,
g_free (e);
return FALSE;
}
- new_list = g_list_prepend (event_listeners, e);
- if (!new_list)
- {
- listener_entry_free (e);
- return FALSE;
- }
- event_listeners = new_list;
+ event_listeners = g_list_prepend (event_listeners, e);
dbus_error_init (&d_error);
for (i = 0; i < matchrule_array->len; i++)
{
diff --git a/atspi/atspi-misc.c b/atspi/atspi-misc.c
index ea132fb..4cd3ed4 100644
--- a/atspi/atspi-misc.c
+++ b/atspi/atspi-misc.c
@@ -324,12 +324,8 @@ add_app_to_desktop (AtspiAccessible *a, const char *bus_name)
AtspiAccessible *obj = ref_accessible (bus_name, atspi_path_root);
if (obj)
{
- GList *new_list = g_list_append (a->children, obj);
- if (new_list)
- {
- a->children = new_list;
- return TRUE;
- }
+ a->children = g_list_append (a->children, obj);
+ return TRUE;
}
else
{
diff --git a/atspi/atspi-relation.c b/atspi/atspi-relation.c
index 7493ecf..82bb668 100644
--- a/atspi/atspi-relation.c
+++ b/atspi/atspi-relation.c
@@ -99,11 +99,8 @@ _atspi_relation_new_from_iter (DBusMessageIter *iter)
while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
{
AtspiAccessible *accessible;
- GArray *new_array;
accessible = _atspi_dbus_return_accessible_from_iter (&iter_array);
- new_array = g_array_append_val (relation->targets, accessible);
- if (new_array)
- relation->targets = new_array;
+ relation->targets = g_array_append_val (relation->targets, accessible);
/* Iter was moved already, so no need to call dbus_message_iter_next */
}
return relation;
diff --git a/atspi/atspi-stateset.c b/atspi/atspi-stateset.c
index 54622ec..b5619e8 100644
--- a/atspi/atspi-stateset.c
+++ b/atspi/atspi-stateset.c
@@ -299,11 +299,7 @@ atspi_state_set_get_states (AtspiStateSet *set)
for (i = 0; i < 64; i++)
{
if (set->states & val)
- {
- GArray *new_array = g_array_append_val (ret, i);
- if (new_array)
- ret = new_array;
- }
+ ret = g_array_append_val (ret, i);
val <<= 1;
}
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]