Merge lp:~charlesk/indicator-messages/fix-937438 into lp:indicator-messages/0.3

Proposed by Charles Kerr
Status: Merged
Approved by: Ted Gould
Approved revision: 254
Merged at revision: 250
Proposed branch: lp:~charlesk/indicator-messages/fix-937438
Merge into: lp:indicator-messages/0.3
Diff against target: 127 lines (+61/-57)
1 file modified
src/status-items.c (+61/-57)
To merge this branch: bzr merge lp:~charlesk/indicator-messages/fix-937438
Reviewer Review Type Date Requested Status
Lars Karlitski (community) Approve
Ted Gould (community) Approve
Review via email: mp+94017@code.launchpad.net

Description of the change

The code seems to be fine. It looks like Coverity is throwing this warning because it's confused by the overlapping goto's.

I've resolved this by not using goto, but maybe there's a simpler way of placating Coverity here?

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

On Tue, 2012-02-21 at 16:34 +0000, charles wrote:
> The code seems to be fine. It looks like Coverity is throwing this
> warning because it's confused by the overlapping goto's.

Yeah, I agree, but in general we should probably get rid of goto's. I
was probably just being lazy when I wrote this code anyway, I like the
updated code better :-)

  review approve
  status approved

review: Approve
Revision history for this message
Lars Karlitski (larsu) wrote :

Extra points for getting rid of the gpointer -> gchar * cast ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/status-items.c'
--- src/status-items.c 2011-07-13 20:17:58 +0000
+++ src/status-items.c 2012-02-21 16:33:19 +0000
@@ -253,62 +253,66 @@
253static gboolean253static gboolean
254load_status_provider (gpointer dir)254load_status_provider (gpointer dir)
255{255{
256 gchar * provider = (gchar *)dir;256 gchar * provider = dir;
257257
258 if (!g_file_test(provider, G_FILE_TEST_EXISTS)) {258 /* load the module */
259 goto exit_final;259 GModule * module = NULL;
260 }260 if (g_file_test(provider, G_FILE_TEST_EXISTS)) {
261261 g_debug("Loading status provider: %s", provider);
262 g_debug("Loading status provider: %s", provider);262 module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
263263 if (module == NULL) {
264 GModule * module;264 g_warning("Unable to open module: %s", provider);
265265 }
266 module = g_module_open(provider, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);266 }
267 if (module == NULL) {267
268 g_warning("Unable to module for: %s", provider);268 /* find the status provider's GType */
269 goto exit_module_fail;269 GType provider_type = 0;
270 }270 if (module != NULL) {
271271 GType (*type_func) (void);
272 /* Got it */272 if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) {
273 GType (*type_func) (void);273 g_warning("Unable to find type symbol in: %s", provider);
274 if (!g_module_symbol(module, STATUS_PROVIDER_EXPORT_S, (gpointer *)&type_func)) {274 } else {
275 g_warning("Unable to find type symbol in: %s", provider);275 provider_type = type_func();
276 goto exit_module_fail;276 if (provider_type == 0) {
277 }277 g_warning("Unable to create type from: %s", provider);
278278 }
279 GType provider_type = type_func();279 }
280 if (provider_type == 0) {280 }
281 g_warning("Unable to create type from: %s", provider);281
282 goto exit_module_fail;282 /* instantiate the status provider */
283 }283 StatusProvider * sprovider = NULL;
284284 if (provider_type != 0) {
285 StatusProvider * sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL));285 sprovider = STATUS_PROVIDER(g_object_new(provider_type, NULL));
286 if (sprovider == NULL) {286 if (sprovider == NULL) {
287 g_warning("Unable to build provider from: %s", provider);287 g_warning("Unable to build provider from: %s", provider);
288 goto exit_module_fail;288 }
289 }289 }
290290
291 /* On update let's talk to all of them and create the aggregate291 /* use the provider */
292 value to export */292 if (sprovider != NULL) {
293 g_signal_connect(G_OBJECT(sprovider), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED, G_CALLBACK(update_status), NULL);293 /* On update let's talk to all of them and create the aggregate
294294 value to export */
295 /* Attach the module object to the status provider so295 g_signal_connect(G_OBJECT(sprovider),
296 that when the status provider is free'd the module296 STATUS_PROVIDER_SIGNAL_STATUS_CHANGED,
297 is close automatically. */297 G_CALLBACK(update_status), NULL);
298 g_object_set_data_full(G_OBJECT(sprovider), "status-provider-module", module, module_destroy_in_idle);298
299299 /* Attach the module object to the status provider so
300 status_providers = g_list_prepend(status_providers, sprovider);300 that when the status provider is free'd the module
301301 is closed automatically. */
302 /* Force and update every time just so we know we're302 g_object_set_data_full(G_OBJECT(sprovider),
303 in a consistent state*/303 "status-provider-module",
304 update_status();304 module, module_destroy_in_idle);
305305 module = NULL; /* don't close module in this func */
306 goto exit_final;306
307307 status_providers = g_list_prepend(status_providers, sprovider);
308exit_module_fail:308
309 g_module_close(module);309 /* Force an update to ensure a consistent state */
310310 update_status();
311exit_final:311 }
312
313 /* cleanup */
314 if (module != NULL)
315 g_module_close(module);
312 g_free(provider);316 g_free(provider);
313 return FALSE;317 return FALSE; /* only call this idle func once */
314}318}

Subscribers

People subscribed via source and target branches