[gnome-settings-daemon] power: Do not overflow when pressing the keyboard brightness down button



commit d361fcee80bbcf8cf2dd692eb91b05800b29f5fb
Author: Richard Hughes <richard hughsie com>
Date:   Mon Mar 5 17:10:56 2012 +0000

    power: Do not overflow when pressing the keyboard brightness down button
    
    Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=670116

 plugins/power/gsd-power-manager.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index b6ca32a..5465f0c 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -136,8 +136,10 @@ static const gchar introspection_xml[] =
 static int
 abs_to_percentage (int min, int max, int value)
 {
-	g_return_val_if_fail (max > min, -1);
-	return (((value - min) * 100) / (max - min));
+        g_return_val_if_fail (max > min, -1);
+        g_return_val_if_fail (value < min, -1);
+        g_return_val_if_fail (value > max, -1);
+        return (((value - min) * 100) / (max - min));
 }
 #define ABS_TO_PERCENTAGE(min, max, value) abs_to_percentage(min, max, value)
 #define PERCENTAGE_TO_ABS(min, max, value) (min + (((max - min) * value) / 100))
@@ -3892,7 +3894,7 @@ handle_method_call_keyboard (GsdPowerManager *manager,
                              GVariant *parameters,
                              GDBusMethodInvocation *invocation)
 {
-        guint step;
+        gint step;
         gint value = -1;
         gboolean ret;
         guint percentage;



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