[gnome-power-manager/gnome-2-28] Fix up all the issues reported by clang



commit e1d7b1f288b945899dbfa987c4b61f9e2f22bed5
Author: Richard Hughes <richard hughsie com>
Date:   Tue Sep 22 09:49:03 2009 +0100

    Fix up all the issues reported by clang

 src/gpm-brightness-xrandr.c |    4 +--
 src/gpm-graph-widget.c      |   60 +++++++++++++++++++++---------------------
 src/gpm-prefs-core.c        |    4 +--
 src/gpm-screensaver.c       |    9 +-----
 src/gpm-statistics.c        |    8 ++---
 5 files changed, 37 insertions(+), 48 deletions(-)
---
diff --git a/src/gpm-brightness-xrandr.c b/src/gpm-brightness-xrandr.c
index bcd026f..ffc78cd 100644
--- a/src/gpm-brightness-xrandr.c
+++ b/src/gpm-brightness-xrandr.c
@@ -584,9 +584,7 @@ gpm_brightness_xrandr_filter_xevents (GdkXEvent *xevent, GdkEvent *event, gpoint
 	GpmBrightnessXRandR *brightness = GPM_BRIGHTNESS_XRANDR (data);
 	if (event->type == GDK_NOTHING)
 		return GDK_FILTER_CONTINUE;
-	egg_warning ("Type %i", event->type);
-	if (FALSE)
-		gpm_brightness_xrandr_may_have_changed (brightness);
+	gpm_brightness_xrandr_may_have_changed (brightness);
 	return GDK_FILTER_CONTINUE;
 }
 
diff --git a/src/gpm-graph-widget.c b/src/gpm-graph-widget.c
index 38616f5..e4793fd 100644
--- a/src/gpm-graph-widget.c
+++ b/src/gpm-graph-widget.c
@@ -94,13 +94,13 @@ static gboolean
 gpm_graph_widget_key_data_clear (GpmGraphWidget *graph)
 {
 	GpmGraphWidgetKeyData *keyitem;
-	guint a;
+	guint i;
 
 	g_return_val_if_fail (GPM_IS_GRAPH_WIDGET (graph), FALSE);
 
 	/* remove items in list and free */
-	for (a=0; a<g_slist_length (graph->priv->key_data); a++) {
-		keyitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, a);
+	for (i=0; i<g_slist_length (graph->priv->key_data); i++) {
+		keyitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, i);
 		g_free (keyitem->desc);
 		g_free (keyitem);
 	}
@@ -483,7 +483,8 @@ gpm_get_axis_label (GpmGraphWidgetType axis, gfloat value)
 static void
 gpm_graph_widget_draw_grid (GpmGraphWidget *graph, cairo_t *cr)
 {
-	gfloat a, b;
+	guint i;
+	gfloat b;
 	gdouble dotted[] = {1., 2.};
 	gfloat divwidth  = (gfloat)graph->priv->box_width / 10.0f;
 	gfloat divheight = (gfloat)graph->priv->box_height / 10.0f;
@@ -495,16 +496,16 @@ gpm_graph_widget_draw_grid (GpmGraphWidget *graph, cairo_t *cr)
 
 	/* do vertical lines */
 	cairo_set_source_rgb (cr, 0.1, 0.1, 0.1);
-	for (a=1; a<10; a++) {
-		b = graph->priv->box_x + (a * divwidth);
+	for (i=1; i<10; i++) {
+		b = graph->priv->box_x + ((gfloat) i * divwidth);
 		cairo_move_to (cr, (gint)b + 0.5f, graph->priv->box_y);
 		cairo_line_to (cr, (gint)b + 0.5f, graph->priv->box_y + graph->priv->box_height);
 		cairo_stroke (cr);
 	}
 
 	/* do horizontal lines */
-	for (a=1; a<10; a++) {
-		b = graph->priv->box_y + (a * divheight);
+	for (i=1; i<10; i++) {
+		b = graph->priv->box_y + ((gfloat) i * divheight);
 		cairo_move_to (cr, graph->priv->box_x, (gint)b + 0.5f);
 		cairo_line_to (cr, graph->priv->box_x + graph->priv->box_width, (int)b + 0.5f);
 		cairo_stroke (cr);
@@ -523,7 +524,8 @@ gpm_graph_widget_draw_grid (GpmGraphWidget *graph, cairo_t *cr)
 static void
 gpm_graph_widget_draw_labels (GpmGraphWidget *graph, cairo_t *cr)
 {
-	gfloat a, b;
+	guint i;
+	gfloat b;
 	gchar *text;
 	gfloat value;
 	gfloat divwidth  = (gfloat)graph->priv->box_width / 10.0f;
@@ -538,17 +540,17 @@ gpm_graph_widget_draw_labels (GpmGraphWidget *graph, cairo_t *cr)
 
 	/* do x text */
 	cairo_set_source_rgb (cr, 0, 0, 0);
-	for (a=0; a<11; a++) {
-		b = graph->priv->box_x + (a * divwidth);
-		value = ((length_x / 10.0f) * (gfloat) a) + (gfloat) graph->priv->start_x;
+	for (i=0; i<11; i++) {
+		b = graph->priv->box_x + ((gfloat) i * divwidth);
+		value = ((length_x / 10.0f) * (gfloat) i) + (gfloat) graph->priv->start_x;
 		text = gpm_get_axis_label (graph->priv->type_x, value);
 
 		pango_layout_set_text (graph->priv->layout, text, -1);
 		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
 		/* have data points 0 and 10 bounded, but 1..9 centered */
-		if (a == 0)
+		if (i == 0)
 			offsetx = 2.0;
-		else if (a == 10)
+		else if (i == 10)
 			offsetx = ink_rect.width;
 		else
 			offsetx = (ink_rect.width / 2.0f);
@@ -561,18 +563,18 @@ gpm_graph_widget_draw_labels (GpmGraphWidget *graph, cairo_t *cr)
 	}
 
 	/* do y text */
-	for (a=0; a<11; a++) {
-		b = graph->priv->box_y + (a * divheight);
-		value = ((gfloat) length_y / 10.0f) * (10 - a) + graph->priv->start_y;
+	for (i=0; i<11; i++) {
+		b = graph->priv->box_y + ((gfloat) i * divheight);
+		value = ((gfloat) length_y / 10.0f) * (10 - (gfloat) i) + graph->priv->start_y;
 		text = gpm_get_axis_label (graph->priv->type_y, value);
 
 		pango_layout_set_text (graph->priv->layout, text, -1);
 		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
 
 		/* have data points 0 and 10 bounded, but 1..9 centered */
-		if (a == 10)
+		if (i == 10)
 			offsety = 0;
-		else if (a == 0)
+		else if (i == 0)
 			offsety = ink_rect.height;
 		else
 			offsety = (ink_rect.height / 2.0f);
@@ -596,18 +598,16 @@ gpm_graph_widget_draw_labels (GpmGraphWidget *graph, cairo_t *cr)
 static guint
 gpm_graph_widget_get_y_label_max_width (GpmGraphWidget *graph, cairo_t *cr)
 {
-	gfloat a, b;
+	guint i;
 	gchar *text;
 	gint value;
-	gfloat divheight = (gfloat)graph->priv->box_height / 10.0f;
 	gint length_y = graph->priv->stop_y - graph->priv->start_y;
 	PangoRectangle ink_rect, logical_rect;
 	guint biggest = 0;
 
 	/* do y text */
-	for (a=0; a<11; a++) {
-		b = graph->priv->box_y + (a * divheight);
-		value = (length_y / 10) * (10 - a) + graph->priv->start_y;
+	for (i=0; i<11; i++) {
+		value = (length_y / 10) * (10 - (gfloat) i) + graph->priv->start_y;
 		text = gpm_get_axis_label (graph->priv->type_y, value);
 		pango_layout_set_text (graph->priv->layout, text, -1);
 		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
@@ -995,15 +995,15 @@ gpm_graph_widget_draw_legend (GpmGraphWidget *graph, gint x, gint y, gint width,
 {
 	cairo_t *cr = graph->priv->cr;
 	gint y_count;
-	guint a;
+	guint i;
 	GpmGraphWidgetKeyData *keydataitem;
 
 	gpm_graph_widget_draw_bounding_box (cr, x, y, width, height);
 	y_count = y + 10;
 
 	/* add the line colors to the legend */
-	for (a=0; a<g_slist_length (graph->priv->key_data); a++) {
-		keydataitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, a);
+	for (i=0; i<g_slist_length (graph->priv->key_data); i++) {
+		keydataitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, i);
 		if (keydataitem == NULL) {
 			/* this shouldn't ever happen */
 			egg_warning ("keydataitem NULL!");
@@ -1032,7 +1032,7 @@ static gboolean
 gpm_graph_widget_legend_calculate_size (GpmGraphWidget *graph, cairo_t *cr,
 					guint *width, guint *height)
 {
-	guint a;
+	guint i;
 	PangoRectangle ink_rect, logical_rect;
 	GpmGraphWidgetKeyData *keydataitem;
 
@@ -1043,8 +1043,8 @@ gpm_graph_widget_legend_calculate_size (GpmGraphWidget *graph, cairo_t *cr,
 	*height = 0;
 
 	/* add the line colors to the legend */
-	for (a=0; a<g_slist_length (graph->priv->key_data); a++) {
-		keydataitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, a);
+	for (i=0; i<g_slist_length (graph->priv->key_data); i++) {
+		keydataitem = (GpmGraphWidgetKeyData *) g_slist_nth_data (graph->priv->key_data, i);
 		*height = *height + GPM_GRAPH_WIDGET_LEGEND_SPACING;
 		pango_layout_set_text (graph->priv->layout, keydataitem->desc, -1);
 		pango_layout_get_pixel_extents (graph->priv->layout, &ink_rect, &logical_rect);
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index 9d7be12..1e5a379 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -468,11 +468,9 @@ gpm_prefs_checkbox_lock_cb (GtkWidget *widget, GpmPrefs *prefs)
 {
 	gboolean checked;
 	gchar *gpm_pref_key;
-	const gchar *widget_name;
 
 	checked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
 
-	widget_name = gtk_widget_get_name (widget);
 	gpm_pref_key = (char *) g_object_get_data (G_OBJECT (widget), "conf_key");
 	egg_debug ("Changing %s to %i", gpm_pref_key, checked);
 	gconf_client_set_bool (prefs->priv->conf, gpm_pref_key, checked, NULL);
@@ -952,7 +950,7 @@ gpm_prefs_init (GpmPrefs *prefs)
 
 	prefs->priv->builder = gtk_builder_new ();
 	retval = gtk_builder_add_from_file (prefs->priv->builder, GPM_DATA "/gpm-prefs.ui", &error);
-	if (error != NULL) {
+	if (retval == 0) {
 		egg_warning ("failed to load ui: %s", error->message);
 		g_error_free (error);
 	}
diff --git a/src/gpm-screensaver.c b/src/gpm-screensaver.c
index 63080a0..514c22b 100644
--- a/src/gpm-screensaver.c
+++ b/src/gpm-screensaver.c
@@ -382,23 +382,18 @@ gpm_screensaver_proxy_status_cb (DBusGProxy *proxy, gboolean status, GpmScreensa
 static void
 gpm_screensaver_init (GpmScreensaver *screensaver)
 {
-	DBusGProxy *proxy;
 	DBusGConnection *connection;
 
 	screensaver->priv = GPM_SCREENSAVER_GET_PRIVATE (screensaver);
 
 	screensaver->priv->gproxy = egg_dbus_proxy_new ();
 	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
-	proxy = egg_dbus_proxy_assign (screensaver->priv->gproxy, connection, GS_LISTENER_SERVICE,
-				       GS_LISTENER_PATH, GS_LISTENER_INTERFACE);
+	egg_dbus_proxy_assign (screensaver->priv->gproxy, connection, GS_LISTENER_SERVICE,
+			       GS_LISTENER_PATH, GS_LISTENER_INTERFACE);
 
 	g_signal_connect (screensaver->priv->gproxy, "proxy-status",
 			  G_CALLBACK (gpm_screensaver_proxy_status_cb),
 			  screensaver);
-#if 0
-	if (proxy != NULL)
-		gpm_screensaver_proxy_connect_more (screensaver);
-#endif
 
 	screensaver->priv->conf = gconf_client_get_default ();
 }
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index cacafb9..c357aa7 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -239,7 +239,6 @@ gpm_stats_update_smooth_data (GPtrArray *list)
 
 	/* convert the y data to a EggArrayFloat array */
 	raw = egg_array_float_new (list->len);
-	convolved = egg_array_float_new (list->len);
 	for (i=0; i<list->len; i++) {
 		point = (GpmPointObj *) g_ptr_array_index (list, i);
 		egg_array_float_set (raw, i, point->y);
@@ -1219,7 +1218,7 @@ gpm_stats_device_removed_cb (DkpClient *client, DkpDevice *device, gpointer user
 
 	/* search the list and remove the object path entry */
 	ret = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (list_store_devices), &iter);
-	do {
+	while (ret) {
 		gtk_tree_model_get (GTK_TREE_MODEL (list_store_devices), &iter, GPM_DEVICES_COLUMN_ID, &id, -1);
 		if (g_strcmp0 (id, object_path) == 0) {
 			gtk_list_store_remove (list_store_devices, &iter);
@@ -1227,7 +1226,7 @@ gpm_stats_device_removed_cb (DkpClient *client, DkpDevice *device, gpointer user
 		}
 		g_free (id);
 		ret = gtk_tree_model_iter_next (GTK_TREE_MODEL (list_store_devices), &iter);
-	} while (ret);
+	};
 }
 
 /**
@@ -1537,7 +1536,7 @@ main (int argc, char *argv[])
 	/* get UI */
 	builder = gtk_builder_new ();
 	retval = gtk_builder_add_from_file (builder, GPM_DATA "/gpm-statistics.ui", &error);
-	if (error != NULL) {
+	if (retval == 0) {
 		egg_warning ("failed to load ui: %s", error->message);
 		g_error_free (error);
 	}
@@ -1633,7 +1632,6 @@ main (int argc, char *argv[])
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_wakeups"));
 	gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
 				 GTK_TREE_MODEL (list_store_wakeups));
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
 
 	/* add columns to the tree view */
 	gpm_stats_add_wakeups_columns (GTK_TREE_VIEW (widget));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]