Added
Link Here
|
1 |
--- src/up-device-battery.c.orig 2022-07-21 09:06:49 UTC |
2 |
+++ src/up-device-battery.c |
3 |
@@ -19,6 +19,7 @@ |
4 |
*/ |
5 |
|
6 |
#include <string.h> |
7 |
+#include <math.h> |
8 |
|
9 |
#include "up-constants.h" |
10 |
#include "up-config.h" |
11 |
@@ -125,7 +126,7 @@ up_device_battery_estimate_power (UpDeviceBattery *sel |
12 |
continue; |
13 |
|
14 |
/* Stop searching if the new reference is further away from the long timeout. */ |
15 |
- if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) |
16 |
+ if (labs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - labs (td)) > labs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) |
17 |
break; |
18 |
|
19 |
ref_td = td; |
20 |
@@ -155,7 +156,7 @@ up_device_battery_estimate_power (UpDeviceBattery *sel |
21 |
*/ |
22 |
if (cur->state == UP_DEVICE_STATE_UNKNOWN) { |
23 |
/* Consider a rate of 0.5W as "no change", otherwise set CHARGING/DISCHARGING */ |
24 |
- if (abs(energy_rate) < 0.5) |
25 |
+ if (fabs(energy_rate) < 0.5) |
26 |
return; |
27 |
else if (energy_rate < 0.0) |
28 |
cur->state = UP_DEVICE_STATE_DISCHARGING; |