From 065b20e0f714915321382aed7fe225002549241d Mon Sep 17 00:00:00 2001
From: Cosimo Cecchi <cosimoc@gnome.org>
Date: Tue, 06 Mar 2012 22:55:45 +0000
Subject: power: fix broken abs_to_percentage() logic

(value < min) and (value > max) will *always* fail, and this function
will always return -1.

https://bugzilla.gnome.org/show_bug.cgi?id=671505
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 5465f0c..78876ce 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -137,8 +137,8 @@ static int
 abs_to_percentage (int min, int max, int value)
 {
         g_return_val_if_fail (max > min, -1);
-        g_return_val_if_fail (value < min, -1);
-        g_return_val_if_fail (value > max, -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)
--
cgit v0.9.0.2

