[gnome-settings-daemon/gnome-3-6] power: Fix "no devices" error path in gsd-backlight-helper



commit 53846d0e97c5698b322debf23daa276282e06b37
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Oct 11 13:08:03 2012 +0200

    power: Fix "no devices" error path in gsd-backlight-helper
    
    Callers of the D-Bus API didn't get any reasons why the call
    failed, just that it did. Also use a correct return value
    for the helper, not some random unrelated error.

 plugins/power/gsd-backlight-helper.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/plugins/power/gsd-backlight-helper.c b/plugins/power/gsd-backlight-helper.c
index 259d49b..9ccfba3 100644
--- a/plugins/power/gsd-backlight-helper.c
+++ b/plugins/power/gsd-backlight-helper.c
@@ -34,6 +34,7 @@
 #define GSD_BACKLIGHT_HELPER_EXIT_CODE_FAILED			1
 #define GSD_BACKLIGHT_HELPER_EXIT_CODE_ARGUMENTS_INVALID	3
 #define GSD_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER		4
+#define GSD_BACKLIGHT_HELPER_EXIT_CODE_NO_DEVICES		5
 
 static gchar *
 gsd_backlight_helper_get_type (GList *devices, const gchar *type)
@@ -58,10 +59,8 @@ gsd_backlight_helper_get_best_backlight ()
 
 	client = g_udev_client_new (NULL);
 	devices = g_udev_client_query_by_subsystem (client, "backlight");
-	if (devices == NULL) {
-		g_warning ("failed to find any devices");
+	if (devices == NULL)
 		goto out;
-	}
 
 	/* search the backlight devices and prefer the types:
 	 * firmware -> platform -> raw */
@@ -169,7 +168,10 @@ main (int argc, char *argv[])
 	/* find device */
 	filename = gsd_backlight_helper_get_best_backlight ();
 	if (filename == NULL) {
-		retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_INVALID_USER;
+		retval = GSD_BACKLIGHT_HELPER_EXIT_CODE_NO_DEVICES;
+		g_print ("%s: %s\n",
+			 "Could not get or set the value of the backlight",
+			 "No backlight devices present");
 		goto out;
 	}
 



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