From 99d2659efca889f1ef8ab5b168e49f63de8edadb Mon Sep 17 00:00:00 2001 From: Landry Breuil Date: Tue, 9 Aug 2022 19:01:46 +0200 Subject: battery: Fix some warnings building natively on OpenBSD with clang 13, i get those warnings: ../src/up-device-battery.c:128:53: warning: absolute value function 'abs' given an argument of type 'gint64' (aka 'long long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) ^ ../src/up-device-battery.c:128:53: note: use function 'llabs' instead if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) ^~~ llabs ../src/up-device-battery.c:128:65: warning: absolute value function 'abs' given an argument of type 'long long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value] if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) ^ ../src/up-device-battery.c:128:65: note: use function 'llabs' instead if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) ^~~ llabs --- src/up-device-battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/up-device-battery.c b/src/up-device-battery.c index c814d9f..b2ed74f 100644 --- a/src/up-device-battery.c +++ b/src/up-device-battery.c @@ -125,7 +125,7 @@ up_device_battery_estimate_power (UpDeviceBattery *self, UpBatteryValues *cur) continue; /* Stop searching if the new reference is further away from the long timeout. */ - if (abs(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - abs (td)) > abs(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) + if (ABS(UP_DAEMON_LONG_TIMEOUT * G_USEC_PER_SEC - ABS (td)) > ABS(UP_DAEMON_SHORT_TIMEOUT * G_USEC_PER_SEC - ref_td)) break; ref_td = td; -- cgit v1.2.1