[gnome-color-manager] Make some fixes as suggested by clang



commit bd276c02a24cb969876d878b68d219855b2bde61
Author: Richard Hughes <richard hughsie com>
Date:   Wed Nov 4 13:16:29 2009 +0000

    Make some fixes as suggested by clang

 src/gcm-prefs.c   |    4 +++-
 src/gcm-utils.c   |    2 +-
 src/gcm-xserver.c |   13 ++++++++++---
 3 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index df3ed5b..7c5103c 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -731,14 +731,16 @@ static void
 gcm_prefs_check_calibration_hardware (void)
 {
 	gboolean ret;
+#ifdef GCM_HARDWARE_DETECTION
 	GtkWidget *widget;
+#endif
 
 	/* find whether we have hardware installed */
 	ret = gcm_prefs_has_hardware_device_attached ();
-	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_calibrate"));
 
 #ifdef GCM_HARDWARE_DETECTION
 	/* disable the button if no supported hardware is found */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_calibrate"));
 	gtk_widget_set_sensitive (widget, ret);
 #else
 	egg_debug ("not setting calibrate button %s as not compiled with hardware detection", ret ? "sensitive" : "insensitive");
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index f439b41..6737f1f 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -272,7 +272,7 @@ gcm_utils_set_output_gamma (GnomeRROutput *output, GError **error)
 	GcmXserver *xserver = NULL;
 	GnomeRRCrtc *crtc;
 	gint x, y;
-	gchar *filename;
+	gchar *filename = NULL;
 	const gchar *output_name;
 
 	/* get CLUT */
diff --git a/src/gcm-xserver.c b/src/gcm-xserver.c
index 54f3508..61ee552 100644
--- a/src/gcm-xserver.c
+++ b/src/gcm-xserver.c
@@ -239,9 +239,9 @@ gcm_xserver_get_output_profile_data (GcmXserver *xserver, const gchar *output_na
 	const gchar *atom_name;
 	gchar *data_tmp = NULL;
 	gint format;
-	gint rc = Success;
+	gint rc = -1;
 	gulong bytes_after;
-	gulong nitems;
+	gulong nitems = 0;
 	Atom atom = None;
 	Atom type;
 	gint i;
@@ -259,7 +259,7 @@ gcm_xserver_get_output_profile_data (GcmXserver *xserver, const gchar *output_na
 	gdk_error_trap_push ();
 	atom = gdk_x11_get_xatom_by_name_for_display (priv->display_gdk, atom_name);
 	resources = XRRGetScreenResources (priv->display, priv->window);
-	for (i = 0; i < resources->noutput; ++i) {
+	for (i = 0; i < resources->noutput; i++) {
 		output = XRRGetOutputInfo (priv->display, resources, resources->outputs[i]);
 		if (g_strcmp0 (output->name, output_name) == 0) {
 			rc = XRRGetOutputProperty (priv->display, resources->outputs[i],
@@ -270,6 +270,13 @@ gcm_xserver_get_output_profile_data (GcmXserver *xserver, const gchar *output_na
 	}
 	gdk_error_trap_pop ();
 
+	/* we failed to match any outputs */
+	if (rc == -1) {
+		if (error != NULL)
+			*error = g_error_new (1, 0, "failed to match adaptor %s", output_name);
+		goto out;
+	}
+
 	/* did the call fail */
 	if (rc != Success) {
 		if (error != NULL)



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