[gnome-color-manager] trivial: use g_set_error() in more places



commit a27e6b29792e8ee2a14bfdf331c5904c3427eaf7
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jan 17 22:22:12 2010 +0000

    trivial: use g_set_error() in more places

 src/gcm-brightness.c       |    6 +---
 src/gcm-calibrate-argyll.c |   60 ++++++++++++++-----------------------------
 src/gcm-calibrate.c        |   15 +++-------
 src/gcm-client.c           |    9 ++----
 src/gcm-device.c           |   15 +++-------
 src/gcm-edid.c             |    3 +-
 src/gcm-profile-lcms1.c    |    6 ++--
 src/gcm-profile.c          |   12 +++------
 src/gcm-tables.c           |    6 +---
 src/gcm-utils.c            |   24 ++++++-----------
 src/gcm-xserver.c          |   27 ++++++-------------
 11 files changed, 62 insertions(+), 121 deletions(-)
---
diff --git a/src/gcm-brightness.c b/src/gcm-brightness.c
index ffeffb1..7d23fa8 100644
--- a/src/gcm-brightness.c
+++ b/src/gcm-brightness.c
@@ -77,8 +77,7 @@ gcm_brightness_set_percentage (GcmBrightness *brightness, guint percentage, GErr
 
 	/* are we connected */
 	if (priv->proxy == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "not connected to gnome-power-manager");
+		g_set_error_literal (error, 1, 0, "not connected to gnome-power-manager");
 		goto out;
 	}
 
@@ -106,8 +105,7 @@ gcm_brightness_get_percentage (GcmBrightness *brightness, guint *percentage, GEr
 
 	/* are we connected */
 	if (priv->proxy == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "not connected to gnome-power-manager");
+		g_set_error_literal (error, 1, 0, "not connected to gnome-power-manager");
 		goto out;
 	}
 
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index 1dcce7f..b054983 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -97,8 +97,7 @@ gcm_calibrate_argyll_get_display (const gchar *output_name, GError **error)
 	for (i=0; split[i] != NULL; i++) {
 		if (g_strstr_len (split[i], -1, "XRandR 1.2 is faulty") != NULL) {
 			ret = FALSE;
-			if (error != NULL)
-				*error = g_error_new (1, 0, "failed to match display as RandR is faulty");
+			g_set_error_literal (error, 1, 0, "failed to match display as RandR is faulty");
 			goto out;
 		}
 		name = g_strdup (split[i]);
@@ -113,8 +112,7 @@ gcm_calibrate_argyll_get_display (const gchar *output_name, GError **error)
 	/* nothing found */
 	if (display == G_MAXUINT) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to match display");
+		g_set_error_literal (error, 1, 0, "failed to match display");
 		goto out;
 	}
 out:
@@ -222,8 +220,7 @@ gcm_calibrate_argyll_get_tool_filename (const gchar *command, GError **error)
 	/* eek */
 	g_free (filename);
 	filename = NULL;
-	if (error != NULL)
-		*error = g_error_new (1, 0, "failed to get filename for %s", command);
+	g_set_error (error, 1, 0, "failed to get filename for %s", command);
 out:
 	return filename;
 }
@@ -269,8 +266,7 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
 	/* get the device */
 	output = gnome_rr_screen_get_output_by_name (priv->rr_screen, output_name);
 	if (output == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get output for %s", output_name);
+		g_set_error (error, 1, 0, "failed to get output for %s", output_name);
 		ret = FALSE;
 		goto out;
 	}
@@ -316,8 +312,7 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
 		vte_terminal_feed_child (VTE_TERMINAL(priv->terminal), "Q", 1);
-		if (error != NULL)
-			*error = g_error_new (1, 0, "user did not attach hardware device");
+		g_set_error_literal (error, 1, 0, "user did not attach hardware device");
 		ret = FALSE;
 		goto out;
 	}
@@ -335,14 +330,12 @@ gcm_calibrate_argyll_display_neutralise (GcmCalibrateArgyll *calibrate_argyll, G
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "calibration was cancelled");
+		g_set_error_literal (error, 1, 0, "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "command failed to run successfully");
+		g_set_error_literal (error, 1, 0, "command failed to run successfully");
 		ret = FALSE;
 		goto out;
 	}
@@ -417,14 +410,12 @@ gcm_calibrate_argyll_display_generate_patches (GcmCalibrateArgyll *calibrate_arg
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "calibration was cancelled");
+		g_set_error_literal (error, 1, 0, "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "command failed to run successfully");
+		g_set_error_literal (error, 1, 0, "command failed to run successfully");
 		ret = FALSE;
 		goto out;
 	}
@@ -494,14 +485,12 @@ gcm_calibrate_argyll_display_draw_and_measure (GcmCalibrateArgyll *calibrate_arg
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "calibration was cancelled");
+		g_set_error_literal (error, 1, 0, "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "command failed to run successfully");
+		g_set_error_literal (error, 1, 0, "command failed to run successfully");
 		ret = FALSE;
 		goto out;
 	}
@@ -594,14 +583,12 @@ gcm_calibrate_argyll_display_generate_profile (GcmCalibrateArgyll *calibrate_arg
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "calibration was cancelled");
+		g_set_error_literal (error, 1, 0, "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "command failed to run successfully");
+		g_set_error_literal (error, 1, 0, "command failed to run successfully");
 		ret = FALSE;
 		goto out;
 	}
@@ -660,8 +647,7 @@ gcm_calibrate_argyll_device_setup (GcmCalibrateArgyll *calibrate_argyll, GError
 
 	/* get result */
 	if (priv->response != GTK_RESPONSE_OK) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "user did not follow calibration steps");
+		g_set_error_literal (error, 1, 0, "user did not follow calibration steps");
 		ret = FALSE;
 		goto out;
 	}
@@ -777,14 +763,12 @@ gcm_calibrate_argyll_device_measure (GcmCalibrateArgyll *calibrate_argyll, GErro
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "calibration was cancelled");
+		g_set_error_literal (error, 1, 0, "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "command failed to run successfully");
+		g_set_error_literal (error, 1, 0, "command failed to run successfully");
 		ret = FALSE;
 		goto out;
 	}
@@ -873,14 +857,12 @@ gcm_calibrate_argyll_device_generate_profile (GcmCalibrateArgyll *calibrate_argy
 
 	/* get result */
 	if (priv->response == GTK_RESPONSE_CANCEL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "calibration was cancelled");
+		g_set_error_literal (error, 1, 0, "calibration was cancelled");
 		ret = FALSE;
 		goto out;
 	}
 	if (priv->response == GTK_RESPONSE_REJECT) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "command failed to run successfully");
+		g_set_error_literal (error, 1, 0, "command failed to run successfully");
 		ret = FALSE;
 		goto out;
 	}
@@ -947,8 +929,7 @@ gcm_calibrate_argyll_finish (GcmCalibrateArgyll *calibrate_argyll, GError **erro
 	/* we can't have finished with success */
 	if (basename == NULL) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "profile was not generated");
+		g_set_error_literal (error, 1, 0, "profile was not generated");
 		goto out;
 	}
 
@@ -958,8 +939,7 @@ gcm_calibrate_argyll_finish (GcmCalibrateArgyll *calibrate_argyll, GError **erro
 	/* we never finished all the steps */
 	if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "could not find completed profile");
+		g_set_error_literal (error, 1, 0, "could not find completed profile");
 		goto out;
 	}
 
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index a1e5ee2..4098a9d 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -99,16 +99,14 @@ gcm_calibrate_display (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
 	/* coldplug source */
 	if (priv->output_name == NULL) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no output name set");
+		g_set_error_literal (error, 1, 0, "no output name set");
 		goto out;
 	}
 
 	/* coldplug source */
 	if (klass->calibrate_display == NULL) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no support");
+		g_set_error_literal (error, 1, 0, "no support");
 		goto out;
 	}
 
@@ -136,8 +134,7 @@ gcm_calibrate_display (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
 				      "is-crt", TRUE,
 				      NULL);
 		} else {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "user did not choose crt or lcd");
+			g_set_error_literal (error, 1, 0, "user did not choose crt or lcd");
 			ret = FALSE;
 			goto out;
 		}
@@ -181,8 +178,7 @@ gcm_calibrate_display (GcmCalibrate *calibrate, GtkWindow *window, GError **erro
 		response = gtk_dialog_run (GTK_DIALOG (dialog));
 		gtk_widget_destroy (dialog);
 		if (response != GTK_RESPONSE_OK) {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "user did not follow calibration steps");
+			g_set_error_literal (error, 1, 0, "user did not follow calibration steps");
 			ret = FALSE;
 			goto out;
 		}
@@ -246,8 +242,7 @@ gcm_calibrate_device (GcmCalibrate *calibrate, GtkWindow *window, GError **error
 
 	/* coldplug source */
 	if (klass->calibrate_device == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no support");
+		g_set_error_literal (error, 1, 0, "no support");
 		goto out;
 	}
 
diff --git a/src/gcm-client.c b/src/gcm-client.c
index c99de74..c38ac9f 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -854,8 +854,7 @@ gcm_client_add_saved (GcmClient *client, GError **error)
 	groups = g_key_file_get_groups (keyfile, NULL);
 	if (groups == NULL) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get groups");
+		g_set_error_literal (error, 1, 0, "failed to get groups");
 		goto out;
 	}
 
@@ -924,16 +923,14 @@ gcm_client_delete_device (GcmClient *client, GcmDevice *device, GError **error)
 		      "id", &id,
 		      NULL);
 	if (connected) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "device is still connected");
+		g_set_error_literal (error, 1, 0, "device is still connected");
 		goto out;
 	}
 
 	/* try to remove from array */
 	ret = g_ptr_array_remove (client->priv->array, device);
 	if (!ret) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "not found in device array");
+		g_set_error_literal (error, 1, 0, "not found in device array");
 		goto out;
 	}
 
diff --git a/src/gcm-device.c b/src/gcm-device.c
index cd0c680..456e44a 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -287,8 +287,7 @@ gcm_device_save (GcmDevice *device, GError **error)
 		file = g_file_new_for_path (dirname);
 		ret = g_file_make_directory_with_parents (file, NULL, &error_local);
 		if (!ret) {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "failed to create config directory: %s", error_local->message);
+			g_set_error (error, 1, 0, "failed to create config directory: %s", error_local->message);
 			g_error_free (error_local);
 			goto out;
 		}
@@ -299,8 +298,7 @@ gcm_device_save (GcmDevice *device, GError **error)
 	if (!ret) {
 		ret = g_file_set_contents (filename, "#created today", -1, &error_local);
 		if (!ret) {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "failed to create dummy header: %s", error_local->message);
+			g_set_error (error, 1, 0, "failed to create dummy header: %s", error_local->message);
 			g_error_free (error_local);
 			goto out;
 		}
@@ -315,8 +313,7 @@ gcm_device_save (GcmDevice *device, GError **error)
 			/* ignore */
 			g_clear_error (&error_local);
 		} else {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "failed to load existing config: %s", error_local->message);
+			g_set_error (error, 1, 0, "failed to load existing config: %s", error_local->message);
 			g_error_free (error_local);
 			goto out;
 		}
@@ -369,8 +366,7 @@ gcm_device_save (GcmDevice *device, GError **error)
 	data = g_key_file_to_data (keyfile, NULL, &error_local);
 	if (data == NULL) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to convert config: %s", error_local->message);
+		g_set_error (error, 1, 0, "failed to convert config: %s", error_local->message);
 		g_error_free (error_local);
 		goto out;
 	}
@@ -378,8 +374,7 @@ gcm_device_save (GcmDevice *device, GError **error)
 	/* save contents */
 	ret = g_file_set_contents (filename, data, -1, &error_local);
 	if (!ret) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to save config: %s", error_local->message);
+		g_set_error (error, 1, 0, "failed to save config: %s", error_local->message);
 		g_error_free (error_local);
 		goto out;
 	}
diff --git a/src/gcm-edid.c b/src/gcm-edid.c
index a5c30f9..040f70e 100644
--- a/src/gcm-edid.c
+++ b/src/gcm-edid.c
@@ -137,8 +137,7 @@ gcm_edid_parse (GcmEdid *edid, const guint8 *data, GError **error)
 
 	/* check header */
 	if (data[0] != 0x00 || data[1] != 0xff) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to parse header");
+		g_set_error_literal (error, 1, 0, "failed to parse header");
 		ret = FALSE;
 		goto out;
 	}
diff --git a/src/gcm-profile-lcms1.c b/src/gcm-profile-lcms1.c
index 95ba346..180871b 100644
--- a/src/gcm-profile-lcms1.c
+++ b/src/gcm-profile-lcms1.c
@@ -456,7 +456,7 @@ gcm_profile_lcms1_parse_data (GcmProfile *profile, const guint8 *data, gsize len
 	/* load profile into lcms */
 	priv->lcms_profile = cmsOpenProfileFromMem ((LPVOID)data, length);
 	if (priv->lcms_profile == NULL) {
-		*error = g_error_new (1, 0, "failed to load: not an ICC profile_lcms1");
+		g_set_error_literal (error, 1, 0, "failed to load: not an ICC profile");
 		goto out;
 	}
 
@@ -692,7 +692,7 @@ gcm_profile_lcms1_parse_data (GcmProfile *profile, const guint8 *data, gsize len
 			egg_debug ("found MLUT which is a fixed size block");
 			ret = gcm_parser_load_icc_mlut (profile_lcms1, data + tag_offset, tag_size);
 			if (!ret) {
-				*error = g_error_new (1, 0, "failed to load mlut");
+				g_set_error_literal (error, 1, 0, "failed to load mlut");
 				goto out;
 			}
 		}
@@ -702,7 +702,7 @@ gcm_profile_lcms1_parse_data (GcmProfile *profile, const guint8 *data, gsize len
 				priv->adobe_gamma_workaround = TRUE;
 			ret = gcm_parser_load_icc_vcgt (profile_lcms1, data + tag_offset, tag_size);
 			if (!ret) {
-				*error = g_error_new (1, 0, "failed to load vcgt");
+				g_set_error_literal (error, 1, 0, "failed to load vcgt");
 				goto out;
 			}
 		}
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index 4b44133..a8aefbc 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -106,8 +106,7 @@ gcm_profile_parse_data (GcmProfile *profile, const guint8 *data, gsize length, G
 
 	/* do we have support */
 	if (klass->parse_data == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no support");
+		g_set_error_literal (error, 1, 0, "no support");
 		goto out;
 	}
 
@@ -136,8 +135,7 @@ gcm_profile_parse (GcmProfile *profile, const gchar *filename, GError **error)
 	/* load files */
 	ret = g_file_get_contents (filename, &data, (gsize *) &length, &error_local);
 	if (!ret) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to load profile: %s", error_local->message);
+		g_set_error (error, 1, 0, "failed to load profile: %s", error_local->message);
 		g_error_free (error_local);
 		goto out;
 	}
@@ -168,15 +166,13 @@ gcm_profile_save (GcmProfile *profile, const gchar *filename, GError **error)
 
 	/* not loaded */
 	if (priv->size == 0) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "not loaded");
+		g_set_error_literal (error, 1, 0, "not loaded");
 		goto out;
 	}
 
 	/* do we have support */
 	if (klass->save == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no support");
+		g_set_error_literal (error, 1, 0, "no support");
 		goto out;
 	}
 
diff --git a/src/gcm-tables.c b/src/gcm-tables.c
index f4df0ed..c70034d 100644
--- a/src/gcm-tables.c
+++ b/src/gcm-tables.c
@@ -84,8 +84,7 @@ gcm_tables_get_pnp_id (GcmTables *tables, const gchar *pnp_id, GError **error)
 		filename = g_build_filename (priv->data_dir, "pnp.ids", NULL);
 		ret = g_file_test (filename, G_FILE_TEST_EXISTS);
 		if (!ret) {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "could not load %s", filename);
+			g_set_error (error, 1, 0, "could not load %s", filename);
 			goto out;
 		}
 
@@ -108,8 +107,7 @@ gcm_tables_get_pnp_id (GcmTables *tables, const gchar *pnp_id, GError **error)
 	/* look this up in the table */
 	found = g_hash_table_lookup (priv->pnp_table, pnp_id);
 	if (found == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "could not find %s", pnp_id);
+		g_set_error (error, 1, 0, "could not find %s", pnp_id);
 		goto out;
 	}
 
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 3605d45..a2f6bdc 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -286,8 +286,7 @@ gcm_utils_get_gamma_size (GnomeRRCrtc *crtc, GError **error)
 
 	/* no size, or X popped an error */
 	if (size == 0) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get gamma size");
+		g_set_error_literal (error, 1, 0, "failed to get gamma size");
 		goto out;
 	}
 out:
@@ -330,16 +329,14 @@ gcm_utils_set_gamma_for_crtc (GnomeRRCrtc *crtc, GcmClut *clut, GError **error)
 	array = gcm_clut_get_array (clut);
 	if (array == NULL) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get CLUT data");
+		g_set_error_literal (error, 1, 0, "failed to get CLUT data");
 		goto out;
 	}
 
 	/* no length? */
 	if (array->len == 0) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no data in the CLUT array");
+		g_set_error_literal (error, 1, 0, "no data in the CLUT array");
 		goto out;
 	}
 
@@ -363,8 +360,7 @@ gcm_utils_set_gamma_for_crtc (GnomeRRCrtc *crtc, GcmClut *clut, GError **error)
 		/* some drivers support Xrandr 1.2, not 1.3 */
 		ret = gcm_utils_set_gamma_fallback (gamma, array->len);
 		if (!ret) {
-			if (error != NULL)
-				*error = g_error_new (1, 0, "failed to set crtc gamma %p (%i) on %i", gamma, array->len, id);
+			g_set_error (error, 1, 0, "failed to set crtc gamma %p (%i) on %i", gamma, array->len, id);
 			goto out;
 		}
 	}
@@ -426,15 +422,13 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
 
 	/* do no set the gamma for non-display types */
 	if (type != GCM_DEVICE_TYPE_ENUM_DISPLAY) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "not a display: %s", id);
+		g_set_error (error, 1, 0, "not a display: %s", id);
 		goto out;
 	}
 
 	/* should be set for display types */
 	if (output_name == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no output name for display: %s", id);
+		g_set_error (error, 1, 0, "no output name for display: %s", id);
 		goto out;
 	}
 
@@ -454,16 +448,14 @@ gcm_utils_set_gamma_for_device (GcmDevice *device, GError **error)
 		goto out;
 	output = gnome_rr_screen_get_output_by_name (rr_screen, output_name);
 	if (output == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "no output for device: %s [%s]", id, output_name);
+		g_set_error (error, 1, 0, "no output for device: %s [%s]", id, output_name);
 		goto out;
 	}
 
 	/* get crtc size */
 	crtc = gnome_rr_output_get_crtc (output);
 	if (crtc == NULL) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get crtc for device: %s", id);
+		g_set_error (error, 1, 0, "failed to get crtc for device: %s", id);
 		goto out;
 	}
 
diff --git a/src/gcm-xserver.c b/src/gcm-xserver.c
index f0ea0e1..1038d9e 100644
--- a/src/gcm-xserver.c
+++ b/src/gcm-xserver.c
@@ -108,15 +108,13 @@ gcm_xserver_get_root_window_profile_data (GcmXserver *xserver, guint8 **data, gs
 
 	/* did the call fail */
 	if (rc != Success) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get %s atom with rc %i", atom_name, rc);
+		g_set_error (error, 1, 0, "failed to get %s atom with rc %i", atom_name, rc);
 		goto out;
 	}
 
 	/* was nothing found */
 	if (nitems == 0) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "%s atom has not been set", atom_name);
+		g_set_error (error, 1, 0, "%s atom has not been set", atom_name);
 		goto out;
 	}
 
@@ -209,8 +207,7 @@ gcm_xserver_set_root_window_profile_data (GcmXserver *xserver, const guint8 *dat
 
 	/* did the call fail */
 	if (rc != Success) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to set %s atom with rc %i", atom_name, rc);
+		g_set_error (error, 1, 0, "failed to set %s atom with rc %i", atom_name, rc);
 		goto out;
 	}
 
@@ -257,8 +254,7 @@ gcm_xserver_remove_root_window_profile (GcmXserver *xserver, GError **error)
 	/* did the call fail */
 	if (rc != Success) {
 		ret = FALSE;
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to delete %s root window atom with rc %i", atom_name, rc);
+		g_set_error (error, 1, 0, "failed to delete %s root window atom with rc %i", atom_name, rc);
 		goto out;
 	}
 out:
@@ -317,22 +313,19 @@ gcm_xserver_get_output_profile_data (GcmXserver *xserver, const gchar *output_na
 
 	/* 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);
+		g_set_error (error, 1, 0, "failed to match adaptor %s", output_name);
 		goto out;
 	}
 
 	/* did the call fail */
 	if (rc != Success) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to get %s atom with rc %i", atom_name, rc);
+		g_set_error (error, 1, 0, "failed to get %s atom with rc %i", atom_name, rc);
 		goto out;
 	}
 
 	/* was nothing found */
 	if (nitems == 0) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "%s atom has not been set", atom_name);
+		g_set_error (error, 1, 0, "%s atom has not been set", atom_name);
 		goto out;
 	}
 
@@ -436,8 +429,7 @@ gcm_xserver_set_output_profile_data (GcmXserver *xserver, const gchar *output_na
 
 	/* did the call fail */
 	if (rc != Success) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to set output %s atom with rc %i", atom_name, rc);
+		g_set_error (error, 1, 0, "failed to set output %s atom with rc %i", atom_name, rc);
 		goto out;
 	}
 
@@ -491,8 +483,7 @@ gcm_xserver_remove_output_profile (GcmXserver *xserver, const gchar *output_name
 
 	/* did the call fail */
 	if (rc != Success) {
-		if (error != NULL)
-			*error = g_error_new (1, 0, "failed to remove output %s atom with rc %i", atom_name, rc);
+		g_set_error (error, 1, 0, "failed to remove output %s atom with rc %i", atom_name, rc);
 		goto out;
 	}
 



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