[Xfce4-commits] [apps/xfce4-taskmanager] 08/20: Use the proper types, add casts where necessary (bug 14401)

noreply at xfce.org noreply at xfce.org
Wed May 30 22:00:22 CEST 2018


This is an automated email from the git hooks/post-receive script.

l   a   n   d   r   y       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-taskmanager.

commit 1c09b7329b9df1a7a675f4a03b5261bd4edf8698
Author: rim <rozhuk.im at gmail.com>
Date:   Wed May 30 21:46:29 2018 +0200

    Use the proper types, add casts where necessary (bug 14401)
---
 src/process-monitor.c    | 12 ++++++------
 src/process-tree-model.c | 18 +++++++++---------
 src/process-tree-view.c  | 19 ++++++++++---------
 src/settings-dialog.c    |  6 +++---
 src/settings.c           |  4 ++--
 src/task-manager-bsd.c   |  2 +-
 src/task-manager.c       |  4 ++--
 7 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/src/process-monitor.c b/src/process-monitor.c
index 1dc0eb3..3e1bd01 100644
--- a/src/process-monitor.c
+++ b/src/process-monitor.c
@@ -121,7 +121,7 @@ xtm_process_monitor_draw (GtkWidget *widget, cairo_t *cr)
 	XtmProcessMonitor *monitor = XTM_PROCESS_MONITOR (widget);
 	guint minimum_history_length;
 
-	minimum_history_length = gtk_widget_get_allocated_width(widget) / monitor->step_size;
+	minimum_history_length = (guint)(gtk_widget_get_allocated_width(widget) / monitor->step_size);
 	if (monitor->history->len < minimum_history_length)
 		g_array_set_size (monitor->history, minimum_history_length + 1);
 
@@ -136,7 +136,7 @@ xtm_process_monitor_expose (GtkWidget *widget, GdkEventExpose *event __unused)
 	guint minimum_history_length;
 	cairo_t *cr;
 
-	minimum_history_length = widget->allocation.width / monitor->step_size;
+	minimum_history_length = (guint)(widget->allocation.width / monitor->step_size);
 	if (monitor->history->len < minimum_history_length)
 		g_array_set_size (monitor->history, minimum_history_length + 1);
 
@@ -153,7 +153,7 @@ xtm_process_monitor_graph_surface_create (XtmProcessMonitor *monitor, gint width
 	cairo_t *cr;
 	cairo_surface_t *graph_surface;
 	gfloat *peak;
-	gfloat step_size;
+	gdouble step_size;
 	gint i;
 
 	if (monitor->history->len <= 1)
@@ -161,7 +161,7 @@ xtm_process_monitor_graph_surface_create (XtmProcessMonitor *monitor, gint width
 		g_warning ("Cannot paint graph with n_peak <= 1");
 		return NULL;
 	}
-	step_size = monitor->step_size;
+	step_size = (gdouble)monitor->step_size;
 
 	graph_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
 	cr = cairo_create (graph_surface);
@@ -180,7 +180,7 @@ xtm_process_monitor_graph_surface_create (XtmProcessMonitor *monitor, gint width
 	{
 		peak = &g_array_index (monitor->history, gfloat, i);
 		cairo_translate (cr, -step_size, 0);
-		cairo_line_to (cr, width, (1.0 - *peak) * height);
+		cairo_line_to (cr, width, (1.0 - ((gdouble)(*peak))) * height);
 	}
 	cairo_line_to (cr, width, height);
 	cairo_fill (cr);
@@ -201,7 +201,7 @@ xtm_process_monitor_graph_surface_create (XtmProcessMonitor *monitor, gint width
 	{
 		peak = &g_array_index (monitor->history, gfloat, i);
 		cairo_translate (cr, -step_size, 0);
-		cairo_line_to (cr, width, (1.0 - *peak) * height);
+		cairo_line_to (cr, width, (1.0 - ((gdouble)(*peak))) * height);
 	}
 	cairo_stroke (cr);
 
diff --git a/src/process-tree-model.c b/src/process-tree-model.c
index 325b945..deb2ed3 100644
--- a/src/process-tree-model.c
+++ b/src/process-tree-model.c
@@ -137,7 +137,7 @@ xtm_process_tree_model_init (XtmProcessTreeModel *treemodel)
 	treemodel->c_column = XTM_PTV_COLUMN_PID;
 	treemodel->p_column = XTM_PTV_COLUMN_PPID;
 
-	treemodel->stamp = g_random_int ();
+	treemodel->stamp = (gint)g_random_int ();
 	if (treemodel->stamp == 0)
 		treemodel->stamp = 1;
 }
@@ -215,7 +215,7 @@ xtm_process_tree_model_get_iter (GtkTreeModel *model, GtkTreeIter *iter, GtkTree
 	/* Walk the tree to create the iter */
 	for (i = 0; i < depth; i++)
 	{
-		node = g_node_nth_child (node, indices[i]);
+		node = g_node_nth_child (node, (guint)indices[i]);
 		if (node == NULL)
 			break;
 	}
@@ -313,7 +313,7 @@ xtm_process_tree_model_iter_n_children (GtkTreeModel *model, GtkTreeIter *iter)
 		node = treemodel->tree;
 	else
 		node = iter->user_data;
-	return g_node_n_children (node);
+	return (gint)g_node_n_children (node);
 }
 
 static gboolean
@@ -326,7 +326,7 @@ xtm_process_tree_model_iter_nth_child (GtkTreeModel *model, GtkTreeIter *iter, G
 		node = treemodel->tree;
 	else
 		node = parent->user_data;
-	iter->user_data = g_node_nth_child (node, n);
+	iter->user_data = g_node_nth_child (node, (guint)n);
 	/* Make iter only valid if a node has been found */
 	iter->stamp = iter->user_data ? treemodel->stamp : 0;
 	return iter->user_data != NULL;
@@ -589,7 +589,7 @@ static void
 do_path (gpointer data, gpointer user_data)
 {
 	XtmCrossLink *lnk = data;
-	void (*func) (GtkTreePath*) = user_data;
+	void (*func) (GtkTreePath*) = (void (*) (GtkTreePath*))user_data;
 	/* Use path for non-persistent models */
 	g_return_if_fail (lnk->path);
 	func (lnk->path);
@@ -633,7 +633,7 @@ xtm_process_tree_model_row_inserted (XtmProcessTreeModel *treemodel, GtkTreePath
 	/* Need to update all path caches after the insert and increment them with one */
 	if (not_persist)
 		g_sequence_foreach_range (g_sequence_iter_next (lnk->list), g_sequence_get_end_iter (treemodel->list),
-			do_path, gtk_tree_path_next);
+			do_path, (gpointer)gtk_tree_path_next);
 
 	found.parent = treemodel->tree;
 	found.treemodel = treemodel;
@@ -748,7 +748,7 @@ xtm_process_tree_model_row_deleted (XtmProcessTreeModel *treemodel, GtkTreePath
 	/* Need to update all path caches after the remove and decrement them with one */
 	if (not_persist)
 		g_sequence_foreach_range (g_sequence_iter_next (lnk->list), g_sequence_get_end_iter (treemodel->list),
-			do_path, gtk_tree_path_prev);
+			do_path, (gpointer)gtk_tree_path_prev);
 
 	del_node = lnk->tree;
 	old_parent = del_node->parent;
@@ -809,7 +809,7 @@ reorder_children (GNode *parent, gpointer data)
 	new_order = g_new (gint, size);
 	for (i = 0; i < size; i++)
 	{
-		new_order[i] = i;
+		new_order[i] = (gint)i;
 	}
 	i = 0;
 	/* Walk the whole list in the new order */
@@ -832,7 +832,7 @@ reorder_children (GNode *parent, gpointer data)
 			if (c_pos > 0)
 			{
 				/* move the items in between to keep order list in sync with the current tree */
-				memmove (new_order + i + 1, new_order + i, c_pos * sizeof(gint));
+				memmove ((new_order + i + 1), (new_order + i), ((guint)c_pos * sizeof(gint)));
 				moved = TRUE;
 			}
 			/* Store the old position at the new location */
diff --git a/src/process-tree-view.c b/src/process-tree-view.c
index 53f278e..4975775 100644
--- a/src/process-tree-view.c
+++ b/src/process-tree-view.c
@@ -208,11 +208,12 @@ xtm_process_tree_view_init (XtmProcessTreeView *treeview)
 
 	/* Set initial sort column */
 	{
-		guint sort_column_id;
+		guint sort_column_idu;
+		gint sort_column_id;
 		GtkSortType sort_type;
 
-		g_object_get (treeview->settings, "sort-column-id", &sort_column_id, "sort-type", &sort_type, NULL);
-		treeview->sort_column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), treeview->columns_positions[sort_column_id]);
+		g_object_get (treeview->settings, "sort-column-id", &sort_column_idu, "sort-type", &sort_type, NULL);
+		treeview->sort_column = gtk_tree_view_get_column (GTK_TREE_VIEW (treeview), treeview->columns_positions[sort_column_idu]);
 		gtk_tree_view_column_set_sort_indicator (treeview->sort_column, TRUE);
 		gtk_tree_view_column_set_sort_order (treeview->sort_column, sort_type);
 		sort_column_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (treeview->sort_column), "sort-column-id"));
@@ -288,7 +289,7 @@ columns_changed (XtmProcessTreeView *treeview)
 	GList *columns, *l;
 	GtkTreeViewColumn *column;
 	gint column_id;
-	gint i;
+	gushort i;
 
 	columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (treeview));
 	if (g_list_length (columns) < N_COLUMNS)
@@ -311,7 +312,7 @@ columns_changed (XtmProcessTreeView *treeview)
 static void
 read_columns_positions (XtmProcessTreeView *treeview)
 {
-	gint i;
+	gushort i;
 	gchar *columns_positions;
 	gchar **columns_positions_split;
 
@@ -326,7 +327,7 @@ read_columns_positions (XtmProcessTreeView *treeview)
 	{
 		columns_positions_split = g_strsplit (columns_positions, ";", N_COLUMNS + 1);
 		for (i = 0; i < N_COLUMNS && columns_positions_split[i] != NULL; i++)
-			treeview->columns_positions[i] = (gint)g_ascii_strtoll (columns_positions_split[i], NULL, 10);
+			treeview->columns_positions[i] = (gushort)g_ascii_strtoll (columns_positions_split[i], NULL, 10);
 		g_strfreev (columns_positions_split);
 		g_free (columns_positions);
 	}
@@ -336,12 +337,12 @@ static void
 save_columns_positions (XtmProcessTreeView *treeview)
 {
 	gint i;
-	gint offset = 0;
+	gulong offset = 0;
 #define COLUMNS_POSITIONS_STRLEN (N_COLUMNS * 4 + 1)
 	gchar columns_positions[COLUMNS_POSITIONS_STRLEN] = { 0 };
 
 	for (i = 0; i < N_COLUMNS; i++)
-		offset += g_snprintf (&columns_positions[offset], (sizeof(columns_positions) - offset), "%d;", treeview->columns_positions[i]);
+		offset += (gulong)g_snprintf (&columns_positions[offset], (sizeof(columns_positions) - offset), "%d;", treeview->columns_positions[i]);
 
 	g_object_set (treeview->settings, "columns-positions", columns_positions, NULL);
 }
@@ -730,7 +731,7 @@ settings_changed (GObject *object, GParamSpec *pspec, XtmProcessTreeView *treevi
 		}
 		else
 		{
-			g_signal_handlers_disconnect_by_func (treeview->model_tree, G_CALLBACK (expand_row), treeview);
+			g_signal_handlers_disconnect_by_func (treeview->model_tree, (gpointer)G_CALLBACK (expand_row), treeview);
 		}
 	}
 }
diff --git a/src/settings-dialog.c b/src/settings-dialog.c
index 46ab437..93f4891 100644
--- a/src/settings-dialog.c
+++ b/src/settings-dialog.c
@@ -83,7 +83,7 @@ builder_bind_toggle_button (GtkBuilder *builder, gchar *widget_name, XtmSettings
 static void
 combobox_changed (GtkComboBox *combobox, XtmSettings *settings)
 {
-	guint active = gtk_combo_box_get_active (combobox);
+	gint active = gtk_combo_box_get_active (combobox);
 	gchar *setting_name = g_object_get_data (G_OBJECT (combobox), "setting-name");
 	g_object_set (settings, setting_name, active, NULL);
 }
@@ -141,7 +141,7 @@ xtm_settings_dialog_init (XtmSettingsDialog *dialog)
 
 		g_object_get (dialog->settings, "toolbar-style", &toolbar_style, NULL);
 		g_object_set_data (G_OBJECT (combobox), "setting-name", "toolbar-style");
-		gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), toolbar_style);
+		gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), (gint)toolbar_style);
 		g_signal_connect (combobox, "changed", G_CALLBACK (combobox_changed), dialog->settings);
 	}
 
@@ -189,7 +189,7 @@ xtm_settings_dialog_hide (GtkWidget *widget)
 	gtk_widget_hide (XTM_SETTINGS_DIALOG (widget)->window);
 	gtk_window_move (GTK_WINDOW (XTM_SETTINGS_DIALOG (widget)->window), winx, winy);
 #if !GTK_CHECK_VERSION(3, 0, 0)
-	GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
+	GTK_WIDGET_UNSET_FLAGS (widget, (guint)GTK_VISIBLE);
 #endif
 }
 
diff --git a/src/settings.c b/src/settings.c
index 5891b39..4fbf99e 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -188,7 +188,7 @@ transform_string_to_int (const GValue *src, GValue *dst)
 static void
 transform_string_to_uint (const GValue *src, GValue *dst)
 {
-	g_value_set_uint (dst, (gint)strtoul (g_value_get_string (src), NULL, 10));
+	g_value_set_uint (dst, (guint)strtoul (g_value_get_string (src), NULL, 10));
 }
 
 static void
@@ -344,7 +344,7 @@ xtm_settings_save_settings (XtmSettings *settings)
 		}
 
 		data = g_key_file_to_data (rc, &length, NULL);
-		if (!g_file_set_contents (filename, data, length, &error))
+		if (!g_file_set_contents (filename, data, (gssize)length, &error))
 		{
 			g_warning ("Unable to save settings: %s", error->message);
 			g_error_free (error);
diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c
index e921c64..ff5236d 100644
--- a/src/task-manager-bsd.c
+++ b/src/task-manager-bsd.c
@@ -138,7 +138,7 @@ gboolean get_task_list (GArray *task_list)
 			free(args);
 		}
 
-		t.cpu_user = (100.0 * ((double) p.p_pctcpu / FSCALE));
+		t.cpu_user = (100.0f * ((gfloat)p.p_pctcpu / FSCALE));
 		t.cpu_system = 0.0f; /* TODO ? */
 		g_array_append_val(task_list, t);
 	}
diff --git a/src/task-manager.c b/src/task-manager.c
index 0624aa1..68d408e 100644
--- a/src/task-manager.c
+++ b/src/task-manager.c
@@ -297,7 +297,7 @@ task_list_find_for_pid (GArray *task_list, GPid pid, Task **task, guint *idx)
 	{
 		if (NULL != task_tmp)
 		{
-			(*idx) = (((size_t)task_tmp - (size_t)task_list->data) / sizeof(Task));
+			(*idx) = (guint)(((size_t)task_tmp - (size_t)task_list->data) / sizeof(Task));
 		}
 		else
 		{
@@ -545,5 +545,5 @@ set_priority_to_pid (GPid pid, gint priority)
 gint
 task_pid_compare_fn(gconstpointer a, gconstpointer b)
 {
-	return (((Task*)a)->pid - ((Task*)b)->pid);
+	return (((const Task*)a)->pid - ((const Task*)b)->pid);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list