From b6454804274860b4716ed6eae826a340e87408d0 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 29 Feb 2012 14:55:23 -0600 Subject: tweak: use g_clear_object() instead of if-not-null-g_object_unref() --- libindicator/indicator-object.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 17a6d1d..0674913 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -473,12 +473,8 @@ indicator_object_new_from_file (const gchar * file) /* Error, let's drop the object and return NULL. Sad when this happens. */ unrefandout: - if (object != NULL) { - g_object_unref(object); - } - if (module != NULL) { - g_object_unref(module); - } + g_clear_object (&object); + g_clear_object (&module); g_warning("Error building IndicatorObject from file: %s", file); return NULL; } -- cgit v1.2.3 From 9e2278a994df1d5a237e4f21bc191965323653c9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 29 Feb 2012 14:58:03 -0600 Subject: silence Coverity warning "PW.BRANCH_PAST_INITIALIZATION - CID 10615" reported in Bug #939061 Coverity is unhappy that the local variable "priv" is uninitialized if one of the goto branches is followed in this function. Since we only use priv once, a fairly clean way of sidestepping this warning is removing the local variable "priv" and instead using INDICATOR_OBJECT_GET_PRIVATE()'s return pointer directly. --- libindicator/indicator-object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'libindicator') diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c index 0674913..ca821af 100644 --- a/libindicator/indicator-object.c +++ b/libindicator/indicator-object.c @@ -464,9 +464,8 @@ indicator_object_new_from_file (const gchar * file) goto unrefandout; } - IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(object); /* Now we can track the module */ - priv->module = module; + INDICATOR_OBJECT_GET_PRIVATE(object)->module = module; return INDICATOR_OBJECT(object); -- cgit v1.2.3 From c3bd07e8e6679bbda00737b81b2397b93ec5a723 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 2 Mar 2012 10:54:50 -0600 Subject: Copying the name before using it to remove as it seems that the unwatch can cause the name to be free'd in some cases. Odd, but valgrind can find it --- libindicator/indicator-service.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libindicator') diff --git a/libindicator/indicator-service.c b/libindicator/indicator-service.c index e9f3133..11171fc 100644 --- a/libindicator/indicator-service.c +++ b/libindicator/indicator-service.c @@ -588,7 +588,9 @@ unwatch_core (IndicatorService * service, const gchar * name) /* Remove us from the watcher list here */ gpointer watcher_item = g_hash_table_lookup(priv->watchers, name); if (watcher_item != NULL) { - g_hash_table_remove(priv->watchers, name); + gchar * safe_name = g_strdup(name); + g_hash_table_remove(priv->watchers, safe_name); + g_free(safe_name); } else { /* Odd that we couldn't find the person, but, eh */ g_warning("Unable to find watcher who is unwatching: %s", name); -- cgit v1.2.3