From c83536fa740c42f95a01c2a92b3f49dd4d6d800c Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 21 Feb 2012 09:47:19 -0600 Subject: trivial: remove unnecessary cast --- src/status-items.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status-items.c b/src/status-items.c index 25a7aa2..8a38dda 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -253,7 +253,7 @@ module_destroy_in_idle (gpointer data) static gboolean load_status_provider (gpointer dir) { - gchar * provider = (gchar *)dir; + gchar * provider = dir; if (!g_file_test(provider, G_FILE_TEST_EXISTS)) { goto exit_final; -- cgit v1.2.3 From 9e47cefaed786f2161b9def9ecd8c8f4ac2f537a Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 21 Feb 2012 09:47:42 -0600 Subject: trivial: fix comment typo --- src/status-items.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status-items.c b/src/status-items.c index 8a38dda..f80de1c 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -294,7 +294,7 @@ load_status_provider (gpointer dir) /* Attach the module object to the status provider so that when the status provider is free'd the module - is close automatically. */ + is closed automatically. */ g_object_set_data_full(G_OBJECT(sprovider), "status-provider-module", module, module_destroy_in_idle); status_providers = g_list_prepend(status_providers, sprovider); -- cgit v1.2.3 From 5d2abcf7e0e913775c2dd2a3d7817cede0791460 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 21 Feb 2012 09:51:45 -0600 Subject: trivial: fix error message grammar --- src/status-items.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/status-items.c b/src/status-items.c index f80de1c..60533ce 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -265,7 +265,7 @@ load_status_provider (gpointer dir) module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); if (module == NULL) { - g_warning("Unable to module for: %s", provider); + g_warning("Unable to open module: %s", provider); goto exit_module_fail; } -- cgit v1.2.3 From 0961069f7ea384123173e99c06f3aae50b0eaa79 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 21 Feb 2012 10:05:08 -0600 Subject: trivial: fix a comment typo --- src/status-items.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/status-items.c b/src/status-items.c index 60533ce..524e1c4 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -299,8 +299,7 @@ load_status_provider (gpointer dir) status_providers = g_list_prepend(status_providers, sprovider); - /* Force and update every time just so we know we're - in a consistent state*/ + /* Force an update to ensure a consistent state*/ update_status(); goto exit_final; -- cgit v1.2.3 From b3a47ea65fb92a464aa4aa4ae3b1935e923a7986 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 21 Feb 2012 10:27:27 -0600 Subject: silence LP Bug #937438 - Coverity got confused by goto's and gave Coverity PW.BRANCH_PAST_INITIALIZATION - CID 10663 --- src/status-items.c | 97 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/src/status-items.c b/src/status-items.c index 524e1c4..70a2ad9 100644 --- a/src/status-items.c +++ b/src/status-items.c @@ -255,59 +255,64 @@ load_status_provider (gpointer dir) { gchar * provider = dir; - if (!g_file_test(provider, G_FILE_TEST_EXISTS)) { - goto exit_final; - } - - g_debug("Loading status provider: %s", provider); - - GModule * module; - - module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); - if (module == NULL) { - g_warning("Unable to open module: %s", provider); - goto exit_module_fail; + /* load the module */ + GModule * module = NULL; + if (g_file_test(provider, G_FILE_TEST_EXISTS)) { + g_debug("Loading status provider: %s", provider); + module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL); + if (module == NULL) { + g_warning("Unable to open module: %s", provider); + } } - /* Got it */ - GType (*type_func) (void); - if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) { - g_warning("Unable to find type symbol in: %s", provider); - goto exit_module_fail; + /* find the status provider's GType */ + GType provider_type = 0; + if (module != NULL) { + GType (*type_func) (void); + if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) { + g_warning("Unable to find type symbol in: %s", provider); + } else { + provider_type = type_func(); + if (provider_type == 0) { + g_warning("Unable to create type from: %s", provider); + } + } } - GType provider_type = type_func(); - if (provider_type == 0) { - g_warning("Unable to create type from: %s", provider); - goto exit_module_fail; + /* instantiate the status provider */ + StatusProvider * sprovider = NULL; + if (provider_type != 0) { + sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL)); + if (sprovider == NULL) { + g_warning("Unable to build provider from: %s", provider); + } } - StatusProvider * sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL)); - if (sprovider == NULL) { - g_warning("Unable to build provider from: %s", provider); - goto exit_module_fail; + /* use the provider */ + if (sprovider != NULL) { + /* On update let's talk to all of them and create the aggregate + value to export */ + g_signal_connect(G_OBJECT(sprovider), + STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, + G_CALLBACK(update_status), NULL); + + /* Attach the module object to the status provider so + that when the status provider is free'd the module + is closed automatically. */ + g_object_set_data_full(G_OBJECT(sprovider), + "status-provider-module", + module, module_destroy_in_idle); + module = NULL; /* don't close module in this func */ + + status_providers = g_list_prepend(status_providers, sprovider); + + /* Force an update to ensure a consistent state */ + update_status(); } - /* On update let's talk to all of them and create the aggregate - value to export */ - g_signal_connect(G_OBJECT(sprovider), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, G_CALLBACK(update_status), NULL); - - /* Attach the module object to the status provider so - that when the status provider is free'd the module - is closed automatically. */ - g_object_set_data_full(G_OBJECT(sprovider), "status-provider-module", module, module_destroy_in_idle); - - status_providers = g_list_prepend(status_providers, sprovider); - - /* Force an update to ensure a consistent state*/ - update_status(); - - goto exit_final; - -exit_module_fail: - g_module_close(module); - -exit_final: + /* cleanup */ + if (module != NULL) + g_module_close(module); g_free(provider); - return FALSE; + return FALSE; /* only call this idle func once */ } -- cgit v1.2.3