/pidgin/main: 1e257009ac10: Fix Pidgin clang scan-build warnings

Tomasz Wasilczyk twasilczyk at pidgin.im
Thu Apr 3 12:23:44 EDT 2014


Changeset: 1e257009ac10347effe3614fd298dbb0e028bf14
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-04-03 18:23 +0200
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/1e257009ac10

Description:

Fix Pidgin clang scan-build warnings

diffstat:

 pidgin/gtkaccount.c           |   4 ++--
 pidgin/gtkconv.c              |   2 +-
 pidgin/gtknotify.c            |   2 ++
 pidgin/gtkplugin.c            |   3 +++
 pidgin/gtkprefs.c             |  16 ++++++++++++----
 pidgin/gtkstatusbox.c         |   6 +++---
 pidgin/gtkthemes.c            |   5 +++--
 pidgin/gtkwebview.c           |   6 ++----
 pidgin/plugins/extplacement.c |   7 +++++++
 9 files changed, 35 insertions(+), 16 deletions(-)

diffs (170 lines):

diff --git a/pidgin/gtkaccount.c b/pidgin/gtkaccount.c
--- a/pidgin/gtkaccount.c
+++ b/pidgin/gtkaccount.c
@@ -329,7 +329,7 @@ username_nofocus_cb(GtkWidget *widget, G
 	GHashTable *table = NULL;
 	const char *label = NULL;
 
-	if(PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(dialog->prpl_info, get_account_text_table)) {
+	if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(dialog->prpl_info, get_account_text_table)) {
 		table = dialog->prpl_info->get_account_text_table(NULL);
 		label = g_hash_table_lookup(table, "login_label");
 
@@ -708,7 +708,7 @@ add_login_options(AccountPrefsDialog *di
 		const char *value = NULL;
 		char *c;
 
-		if (dialog->account != NULL) {
+		if (dialog->account != NULL && username != NULL) {
 			if(purple_account_user_split_get_reverse(split))
 				c = strrchr(username,
 						purple_account_user_split_get_separator(split));
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -7749,7 +7749,7 @@ pidgin_conv_update_fields(PurpleConversa
 		gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title);
 		if (pidgin_conv_window_is_active_conversation(conv)) {
 			const char* current_title = gtk_window_get_title(GTK_WINDOW(win->window));
-			if (current_title == NULL || strcmp(current_title, title) != 0)
+			if (current_title == NULL || g_strcmp0(current_title, title) != 0)
 				gtk_window_set_title(GTK_WINDOW(win->window), title);
 		}
 
diff --git a/pidgin/gtknotify.c b/pidgin/gtknotify.c
--- a/pidgin/gtknotify.c
+++ b/pidgin/gtknotify.c
@@ -789,6 +789,7 @@ pidgin_notify_emails(PurpleConnection *g
 			g_free(to_text);
 			g_free(from_text);
 			g_free(subject_text);
+			(void)first;
 
 			/* If we don't keep track of this, will leak "data" for each of the notifications except the last */
 			data2 = pidgin_notify_add_mail(mail_dialog->treemodel, account, notification, urls ? *urls : NULL, 0, FALSE, &new_data);
@@ -1737,6 +1738,7 @@ pidgin_create_notification_dialog(Pidgin
 
 	button = gtk_dialog_add_button(GTK_DIALOG(dialog),
 	                               GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+	gtk_widget_set_sensitive(button, TRUE);
 
 	gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
 	gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
diff --git a/pidgin/gtkplugin.c b/pidgin/gtkplugin.c
--- a/pidgin/gtkplugin.c
+++ b/pidgin/gtkplugin.c
@@ -86,6 +86,9 @@ pidgin_plugin_has_prefs(PurplePlugin *pl
 		return TRUE;
 	}
 
+	if (!plugin->info)
+		return FALSE;
+
 	pinfo = plugin->info->prefs_info;
 
 	if (!pinfo)
diff --git a/pidgin/gtkprefs.c b/pidgin/gtkprefs.c
--- a/pidgin/gtkprefs.c
+++ b/pidgin/gtkprefs.c
@@ -4027,8 +4027,12 @@ vv_plugin_changed_cb(const gchar *name, 
 	strcpy(pref + strlen(pref) - strlen("plugin"), "device");
 	devices = get_vv_element_devices(value);
 	if (g_list_find_custom(devices, purple_prefs_get_string(pref),
-	                       (GCompareFunc)strcmp) == NULL)
-		purple_prefs_set_string(pref, g_list_next(devices)->data);
+		(GCompareFunc)strcmp) == NULL)
+	{
+		GList *next = g_list_next(devices);
+		if (next)
+			purple_prefs_set_string(pref, next->data);
+	}
 	widget = pidgin_prefs_dropdown_from_list(vbox, _("_Device"),
 	                                         PURPLE_PREF_STRING, pref, devices);
 	g_list_free_full(devices, g_free);
@@ -4071,8 +4075,12 @@ make_vv_frame(GtkWidget *parent, GtkSize
 	/* Setup device preference */
 	devices = get_vv_element_devices(purple_prefs_get_string(plugin_pref));
 	if (g_list_find_custom(devices, purple_prefs_get_string(device_pref),
-	                       (GCompareFunc)strcmp) == NULL)
-		purple_prefs_set_string(device_pref, g_list_next(devices)->data);
+		(GCompareFunc)strcmp) == NULL)
+	{
+		GList *next = g_list_next(devices);
+		if (next)
+			purple_prefs_set_string(device_pref, next->data);
+	}
 	widget = pidgin_prefs_dropdown_from_list(vbox, _("_Device"),
 	                                         PURPLE_PREF_STRING, device_pref,
 	                                         devices);
diff --git a/pidgin/gtkstatusbox.c b/pidgin/gtkstatusbox.c
--- a/pidgin/gtkstatusbox.c
+++ b/pidgin/gtkstatusbox.c
@@ -316,9 +316,9 @@ icon_box_press_cb(GtkWidget *widget, Gdk
 
 		box->icon_box_menu = gtk_menu_new();
 
-		menu_item = pidgin_new_item_from_stock(box->icon_box_menu, _("Select Buddy Icon"), GTK_STOCK_ADD,
-						     G_CALLBACK(choose_buddy_icon_cb),
-						     box, 0, 0, NULL);
+		pidgin_new_item_from_stock(box->icon_box_menu,
+			_("Select Buddy Icon"), GTK_STOCK_ADD,
+			G_CALLBACK(choose_buddy_icon_cb), box, 0, 0, NULL);
 
 		menu_item = pidgin_new_item_from_stock(box->icon_box_menu, _("Remove"), GTK_STOCK_REMOVE,
 						     G_CALLBACK(remove_buddy_icon_cb),
diff --git a/pidgin/gtkthemes.c b/pidgin/gtkthemes.c
--- a/pidgin/gtkthemes.c
+++ b/pidgin/gtkthemes.c
@@ -272,9 +272,10 @@ void pidgin_themes_load_smiley_theme(con
 			child->sml = g_strndup(i+1, strchr(i, ']') - i - 1);
 			child->files = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 
-			if (theme->list)
+			if (theme->list) {
+				g_return_if_fail(list != NULL);
 				list->next = child;
-			else
+			} else
 				theme->list = child;
 			/* Reverse the Smiley list since it was built in reverse order for efficiency reasons */
 			if (list != NULL)
diff --git a/pidgin/gtkwebview.c b/pidgin/gtkwebview.c
--- a/pidgin/gtkwebview.c
+++ b/pidgin/gtkwebview.c
@@ -1511,7 +1511,6 @@ static void
 pidgin_webview_finalize(GObject *webview)
 {
 	PidginWebViewPriv *priv = PIDGIN_WEBVIEW_GET_PRIVATE(webview);
-	gpointer temp;
 
 	if (priv->inspector_win != NULL)
 		gtk_widget_destroy(GTK_WIDGET(priv->inspector_win));
@@ -1520,9 +1519,8 @@ pidgin_webview_finalize(GObject *webview
 		g_source_remove(priv->loader);
 
 	while (!g_queue_is_empty(priv->load_queue)) {
-		temp = g_queue_pop_head(priv->load_queue);
-		temp = g_queue_pop_head(priv->load_queue);
-		g_free(temp);
+		g_queue_pop_head(priv->load_queue);
+		g_free(g_queue_pop_head(priv->load_queue));
 	}
 	g_queue_free(priv->load_queue);
 
diff --git a/pidgin/plugins/extplacement.c b/pidgin/plugins/extplacement.c
--- a/pidgin/plugins/extplacement.c
+++ b/pidgin/plugins/extplacement.c
@@ -57,6 +57,13 @@ conv_placement_by_number(PidginConversat
 			for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) {
 				win = l->data;
 
+				if (!conv || !conv->active_conv ||
+					!G_TYPE_FROM_INSTANCE(conv->active_conv))
+				{
+					g_warn_if_reached();
+					continue;
+				}
+
 				if (purple_prefs_get_bool("/plugins/gtk/extplacement/placement_number_separate") &&
 					G_TYPE_FROM_INSTANCE(pidgin_conv_window_get_active_conversation(win)) != G_TYPE_FROM_INSTANCE(conv->active_conv))
 					continue;



More information about the Commits mailing list