/pidgin/main: 5ef990c032ad: Fix Finch clang scan-build warnings

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 3 12:45:36 EDT 2014


Changeset: 5ef990c032ad976cf76ad300bf6a183eb4f43aab
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-03 18:45 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/5ef990c032ad

Description:

Fix Finch clang scan-build warnings

diffstat:

 finch/gntplugin.c          |   5 +++++
 finch/libgnt/gntbox.c      |  11 +++++++++++
 finch/libgnt/gntmenu.c     |   2 ++
 finch/libgnt/gnttextview.c |   9 +++++++++
 finch/libgnt/gnttree.c     |   3 ++-
 finch/libgnt/gntwm.c       |   6 ++++++
 finch/libgnt/wms/irssi.c   |   3 +++
 finch/libgnt/wms/s.c       |   3 +++
 8 files changed, 41 insertions(+), 1 deletions(-)

diffs (145 lines):

diff --git a/finch/gntplugin.c b/finch/gntplugin.c
--- a/finch/gntplugin.c
+++ b/finch/gntplugin.c
@@ -83,6 +83,9 @@ has_prefs(PurplePlugin *plugin)
 		return TRUE;
 	}
 
+	if (!plugin->info)
+		return FALSE;
+
 	pinfo = plugin->info->prefs_info;
 	if (!pinfo)
 		return FALSE;
@@ -247,6 +250,8 @@ configure_plugin_cb(GntWidget *button, g
 		return;
 	plugin->ui_data = ui_data = g_new0(FinchPluginUiData, 1);
 
+	g_return_if_fail(plugin->info != NULL);
+
 	if (PURPLE_IS_GNT_PLUGIN(plugin) &&
 			(callback = FINCH_PLUGIN_UI_INFO(plugin)) != NULL)
 	{
diff --git a/finch/libgnt/gntbox.c b/finch/libgnt/gntbox.c
--- a/finch/libgnt/gntbox.c
+++ b/finch/libgnt/gntbox.c
@@ -731,6 +731,11 @@ void gnt_box_sync_children(GntBox *box)
 		int height, width;
 		int x, y;
 
+		if (G_UNLIKELY(w == NULL)) {
+			g_warn_if_reached();
+			continue;
+		}
+
 		if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE))
 			continue;
 
@@ -819,6 +824,12 @@ void gnt_box_readjust(GntBox *box)
 	for (iter = box->list; iter; iter = iter->next)
 	{
 		GntWidget *w = iter->data;
+
+		if (G_UNLIKELY(w == NULL)) {
+			g_warn_if_reached();
+			continue;
+		}
+
 		if (GNT_IS_BOX(w))
 			gnt_box_readjust(GNT_BOX(w));
 		else
diff --git a/finch/libgnt/gntmenu.c b/finch/libgnt/gntmenu.c
--- a/finch/libgnt/gntmenu.c
+++ b/finch/libgnt/gntmenu.c
@@ -121,6 +121,8 @@ menu_tree_add(GntMenu *menu, GntMenuItem
 {
 	char trigger[4] = "\0 )\0";
 
+	g_return_if_fail(item != NULL);
+
 	if ((trigger[1] = gnt_menuitem_get_trigger(item)) && trigger[1] != ' ')
 		trigger[0] = '(';
 
diff --git a/finch/libgnt/gnttextview.c b/finch/libgnt/gnttextview.c
--- a/finch/libgnt/gnttextview.c
+++ b/finch/libgnt/gnttextview.c
@@ -335,6 +335,9 @@ gnt_text_view_clicked(GntWidget *widget,
 		GntTextView *view = GNT_TEXT_VIEW(widget);
 		if (text_view_contains(view, select_start)) {
 			GString *clip;
+
+			g_return_val_if_fail(select_start != NULL, TRUE);
+
 			select_end = gnt_text_view_get_p(view, x - widget->priv.x, y - widget->priv.y);
 			if (select_end < select_start) {
 				gchar *t = select_start;
@@ -758,6 +761,12 @@ int gnt_text_view_tag_change(GntTextView
 				GList *segs, *snext;
 				GntTextLine *line = iter->data;
 				inext = iter->next;
+
+				if (line == NULL) {
+					g_warn_if_reached();
+					continue;
+				}
+
 				for (segs = line->segments; segs; segs = snext) {
 					GntTextSegment *seg = segs->data;
 					snext = segs->next;
diff --git a/finch/libgnt/gnttree.c b/finch/libgnt/gnttree.c
--- a/finch/libgnt/gnttree.c
+++ b/finch/libgnt/gnttree.c
@@ -1314,7 +1314,8 @@ void gnt_tree_sort_row(GntTree *tree, gp
 		else
 			tree->root = row;
 		row->next = s;
-		s->prev = row;  /* s cannot be NULL */
+		g_return_if_fail(s != NULL); /* s cannot be NULL */
+		s->prev = row;
 		row->prev = NULL;
 		newp = g_list_index(tree->list, s) - 1;
 	} else {
diff --git a/finch/libgnt/gntwm.c b/finch/libgnt/gntwm.c
--- a/finch/libgnt/gntwm.c
+++ b/finch/libgnt/gntwm.c
@@ -2251,8 +2251,14 @@ gboolean gnt_wm_process_click(GntWM *wm,
 void gnt_wm_raise_window(GntWM *wm, GntWidget *widget)
 {
 	GntWS *ws = gnt_wm_widget_find_workspace(wm, widget);
+
+	g_return_if_fail(wm != NULL);
+
 	if (wm->cws != ws)
 		gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws));
+
+	g_return_if_fail(wm->cws != NULL);
+
 	if (widget != wm->cws->ordered->data) {
 		GntWidget *wid = wm->cws->ordered->data;
 		wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget);
diff --git a/finch/libgnt/wms/irssi.c b/finch/libgnt/wms/irssi.c
--- a/finch/libgnt/wms/irssi.c
+++ b/finch/libgnt/wms/irssi.c
@@ -155,6 +155,9 @@ irssi_new_window(GntWM *wm, GntWidget *w
 	const char *name;
 	int x, y, w, h;
 
+	g_return_if_fail(win != NULL);
+	g_return_if_fail(wm != NULL);
+
 	name = gnt_widget_get_name(win);
 	if (!name || !strstr(name, "conversation-window")) {
 		if (!GNT_IS_MENU(win) && !GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) {
diff --git a/finch/libgnt/wms/s.c b/finch/libgnt/wms/s.c
--- a/finch/libgnt/wms/s.c
+++ b/finch/libgnt/wms/s.c
@@ -84,6 +84,9 @@ s_new_window(GntWM *wm, GntWidget *win)
 	const char *name;
 	gboolean blist = FALSE;
 
+	g_return_if_fail(win != NULL);
+	g_return_if_fail(wm != NULL);
+
 	if (!GNT_IS_MENU(win)) {
 		getmaxyx(stdscr, maxy, maxx);
 



More information about the Commits mailing list