[gnome-packagekit] trivial: use g_set_error() in more places
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-packagekit] trivial: use g_set_error() in more places
- Date: Sun, 17 Jan 2010 23:15:30 +0000 (UTC)
commit 4673b48cc7edeb03d013da72c1f6239335a22493
Author: Richard Hughes <richard hughsie com>
Date: Sun Jan 17 23:15:09 2010 +0000
trivial: use g_set_error() in more places
src/egg-console-kit.c | 12 ++++--------
src/gpk-dbus-task.c | 2 +-
src/gpk-language.c | 3 +--
src/gpk-service-pack.c | 8 ++++----
4 files changed, 10 insertions(+), 15 deletions(-)
---
diff --git a/src/egg-console-kit.c b/src/egg-console-kit.c
index 9c0f326..d4ac5f0 100644
--- a/src/egg-console-kit.c
+++ b/src/egg-console-kit.c
@@ -76,8 +76,7 @@ egg_console_kit_restart (EggConsoleKit *console, GError **error)
G_TYPE_INVALID, G_TYPE_INVALID);
if (!ret) {
egg_warning ("Couldn't restart: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
+ g_set_error (error, 1, 0, "%s", error_local->message);
g_error_free (error_local);
}
return ret;
@@ -99,8 +98,7 @@ egg_console_kit_stop (EggConsoleKit *console, GError **error)
G_TYPE_INVALID, G_TYPE_INVALID);
if (!ret) {
egg_warning ("Couldn't stop: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
+ g_set_error (error, 1, 0, "%s", error_local->message);
g_error_free (error_local);
}
return ret;
@@ -123,8 +121,7 @@ egg_console_kit_can_stop (EggConsoleKit *console, gboolean *can_stop, GError **e
G_TYPE_BOOLEAN, can_stop, G_TYPE_INVALID);
if (!ret) {
egg_warning ("Couldn't do CanStop: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
+ g_set_error (error, 1, 0, "%s", error_local->message);
g_error_free (error_local);
/* CanStop was only added in new versions of ConsoleKit,
* so assume true if this failed */
@@ -150,8 +147,7 @@ egg_console_kit_can_restart (EggConsoleKit *console, gboolean *can_restart, GErr
G_TYPE_BOOLEAN, can_restart, G_TYPE_INVALID);
if (!ret) {
egg_warning ("Couldn't do CanRestart: %s", error_local->message);
- if (error != NULL)
- *error = g_error_new (1, 0, "%s", error_local->message);
+ g_set_error (error, 1, 0, "%s", error_local->message);
g_error_free (error_local);
/* CanRestart was only added in new versions of ConsoleKit,
* so assume true if this failed */
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 4031730..6c2c2e4 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -636,7 +636,7 @@ gpk_dbus_task_install_package_files_verify (GpkDbusTask *dtask, GPtrArray *array
/* did we click no or exit the window? */
if (button != GTK_RESPONSE_OK) {
- *error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "Aborted");
+ g_set_error_literal (error, GPK_DBUS_ERROR, GPK_DBUS_ERROR_CANCELLED, "Aborted");
ret = FALSE;
goto out;
}
diff --git a/src/gpk-language.c b/src/gpk-language.c
index 66c1167..d99ec79 100644
--- a/src/gpk-language.c
+++ b/src/gpk-language.c
@@ -109,8 +109,7 @@ gpk_language_populate (GpkLanguage *language, GError **error)
filename = g_build_filename ("/usr", "share", "xml", "iso-codes", "iso_639.xml", NULL);
}
if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
- if (error != NULL)
- *error = g_error_new (1, 0, "cannot find source file : '%s'", filename);
+ g_set_error (error, 1, 0, "cannot find source file : '%s'", filename);
goto out;
}
diff --git a/src/gpk-service-pack.c b/src/gpk-service-pack.c
index c41e5e2..393aff0 100644
--- a/src/gpk-service-pack.c
+++ b/src/gpk-service-pack.c
@@ -254,7 +254,7 @@ gpk_pack_resolve_package_ids (gchar **package, GError **error)
package_id = gpk_pack_resolve_package_id (package[i]);
if (package_id == NULL) {
/* TRANSLATORS: cannot resolve name to package name */
- *error = g_error_new (1, 0, _("Could not find any packages named '%s'"), package[i]);
+ g_set_error (error, 1, 0, _("Could not find any packages named '%s'"), package[i]);
ret = FALSE;
break;
}
@@ -266,7 +266,7 @@ gpk_pack_resolve_package_ids (gchar **package, GError **error)
/* no packages */
if (array->len == 0) {
/* TRANSLATORS: cannot find any valid package names */
- *error = g_error_new (1, 0, _("Could not find any valid package names"));
+ g_set_error_literal (error, 1, 0, _("Could not find any valid package names"));
goto out;
}
@@ -330,7 +330,7 @@ gpk_pack_copy_package_lists (const gchar *filename, GError **error)
results = pk_client_get_packages (client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), NULL, NULL, NULL, &error_local);
if (results == NULL) {
/* TRANSLATORS: cannot get package array */
- *error = g_error_new (1, 0, _("Could not get array of installed packages: %s"), error_local->message);
+ g_set_error (error, 1, 0, _("Could not get array of installed packages: %s"), error_local->message);
g_error_free (error_local);
goto out;
}
@@ -349,7 +349,7 @@ gpk_pack_copy_package_lists (const gchar *filename, GError **error)
data = gpk_pack_package_array_to_string (array);
ret = g_file_set_contents (PK_SYSTEM_PACKAGE_LIST_FILENAME, data, -1, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, _("Could not save to file: %s"), error_local->message);
+ g_set_error (error, 1, 0, _("Could not save to file: %s"), error_local->message);
g_error_free (error_local);
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]