~ubuntu-branches/ubuntu/oneiric/gnome-settings-daemon/oneiric-proposed

« back to all changes in this revision

Viewing changes to debian/patches/00git_guard_against_division_by_0.patch

  • Committer: Package Import Robot
  • Author(s): Rodrigo Moya
  • Date: 2011-09-19 17:05:48 UTC
  • mfrom: (1.1.51 upstream)
  • Revision ID: package-import@ubuntu.com-20110919170548-gegm8ewt6qf7v7lp
Tags: 3.1.92-0ubuntu1
* New upstream release
* debian/control:
  - Bump libcolord-dev build dependency
* debian/patches/00git_guard_against_division_by_0.patch:
* debian/patches/00git_dont_crash_if_session_not_ready.patch:
* debian/patches/00git_numlock_status.patch:
* debian/patches/00git_disconnect_callbacks.patch:
  - Remove upstream patches
* debian/patches/06_use_application_indicator.patch:
* debian/patches/16_use_synchronous_notifications.patch:
  - Rebased

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
commit 5be38144f19d1479c908039ffc2991052b06111b
2
 
Author: Bastien Nocera <hadess@hadess.net>
3
 
Date:   Wed Sep 7 16:18:46 2011 +0100
4
 
 
5
 
    power: Make ABS_TO_PERCENTAGE warn on invalid input
6
 
    
7
 
    Works around this problem, whilst producing a warning.
8
 
    https://bugzilla.gnome.org/show_bug.cgi?id=657364
9
 
 
10
 
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
11
 
index a67c998..80aba9d 100644
12
 
--- a/plugins/power/gsd-power-manager.c
13
 
+++ b/plugins/power/gsd-power-manager.c
14
 
@@ -126,7 +126,13 @@ static const gchar introspection_xml[] =
15
 
 #define BRIGHTNESS_STEP_AMOUNT(max) ((max) < 20 ? 1 : (max) / 20)
16
 
 
17
 
 /* take a discrete value with offset and convert to percentage */
18
 
-#define ABS_TO_PERCENTAGE(min, max, value) (((value - min) * 100) / (max - min))
19
 
+static int
20
 
+abs_to_percentage (int min, int max, int value)
21
 
+{
22
 
+       g_return_val_if_fail (max > min, -1);
23
 
+       return (((value - min) * 100) / (max - min));
24
 
+}
25
 
+#define ABS_TO_PERCENTAGE(min, max, value) abs_to_percentage(min, max, value)
26
 
 #define PERCENTAGE_TO_ABS(min, max, value) (min + (((max - min) * value) / 100))
27
 
 
28
 
 #define GSD_POWER_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_POWER_MANAGER, GsdPowerManagerPrivate))