From b21ad6af14dfc3c95c0d912748fcfaf23e7c7a93 Mon Sep 17 00:00:00 2001 From: Sverre Velten Rothmund Date: Mon, 14 Aug 2023 15:02:28 +0200 Subject: [PATCH] multiple: Fix abs(int) usage on float values --- src/drivers/heater/heater.cpp | 2 +- src/drivers/telemetry/hott/messages.cpp | 2 +- .../GeofenceBreachAvoidance/geofence_breach_avoidance.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/drivers/heater/heater.cpp b/src/drivers/heater/heater.cpp index 170bd859a49f..aba6f7066e40 100644 --- a/src/drivers/heater/heater.cpp +++ b/src/drivers/heater/heater.cpp @@ -231,7 +231,7 @@ void Heater::Run() _controller_time_on_usec = math::constrain(_controller_time_on_usec, 0, _controller_period_usec); - if (abs(temperature_delta) < TEMPERATURE_TARGET_THRESHOLD) { + if (fabsf(temperature_delta) < TEMPERATURE_TARGET_THRESHOLD) { _temperature_target_met = true; } else { diff --git a/src/drivers/telemetry/hott/messages.cpp b/src/drivers/telemetry/hott/messages.cpp index 150bc21fe928..f800a0056624 100644 --- a/src/drivers/telemetry/hott/messages.cpp +++ b/src/drivers/telemetry/hott/messages.cpp @@ -249,7 +249,7 @@ build_gps_response(uint8_t *buffer, size_t *size) if (lat < 0) { msg.latitude_ns = 1; - lat = abs(lat); + lat = fabs(lat); } int deg; diff --git a/src/modules/navigator/GeofenceBreachAvoidance/geofence_breach_avoidance.cpp b/src/modules/navigator/GeofenceBreachAvoidance/geofence_breach_avoidance.cpp index f84e24e74ba4..802dacaaf639 100644 --- a/src/modules/navigator/GeofenceBreachAvoidance/geofence_breach_avoidance.cpp +++ b/src/modules/navigator/GeofenceBreachAvoidance/geofence_breach_avoidance.cpp @@ -159,7 +159,7 @@ GeofenceBreachAvoidance::generateLoiterPointForMultirotor(geofence_violation_typ Vector2d test_point; // binary search for the distance from the drone to the geofence in the given direction - while (abs(current_max - current_min) > 0.5f) { + while (fabsf(current_max - current_min) > 0.5f) { test_point = waypointFromBearingAndDistance(_current_pos_lat_lon, _test_point_bearing, current_distance); if (!geofence->isInsidePolygonOrCircle(test_point(0), test_point(1), _current_alt_amsl)) {