[Github-comments] [geany/geany-plugins] Debugger: Fix cppcheck false positive warning (#1017)

Colomban Wendling notifications at xxxxx
Sun Oct 18 17:11:01 UTC 2020


@b4n requested changes on this pull request.

OK, so it's a bug in cppckeck that gets operator priority wrong, right?  Because the code was right, `*array[i]` is `*(array[i])`, not `(*array)[i]`.

Anyway, I think there could be a better loop, and there's at least an issue with the `g_object_ref()` calls.

>  		{
-			g_object_ref(*widgets[i]);
-			gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(*widgets[i])), *widgets[i]);
+			widget = widgets[i];
+			g_object_ref(widget);

That's wrong, isn't it?  It should try to unref `*widget` I believe.

>  			i++;
-		}
-		
+		} while (widget);

I'd rather see it as
```c
for (i = 0; widgets[i]; i++)
{
	GtkWidget **widget_ref = widgets[i];
	g_object_ref(*widget_ref);
	gtk_container_remove(…);
}
```

It's more idiomatic and understandable to me than relying on the variable set in the loop.

>  			g_object_unref(*widgets[i]);
 			i++;
-		}
+		} while (widget);

what's the point here?  You're not using the variable you set in the loop.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/1017#pullrequestreview-511162325
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20201018/75c31a95/attachment.htm>


More information about the Github-comments mailing list