From 7883085e4aae830558137ba085c6385bb1fb7b8e Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Thu, 2 Feb 2017 00:17:43 -0500 Subject: [PATCH] clang-tidy readability-simplify-boolean-expr (#235) --- EKF/ekf.cpp | 7 +------ EKF/gps_checks.cpp | 13 ++----------- EKF/terrain_estimator.cpp | 7 +------ 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/EKF/ekf.cpp b/EKF/ekf.cpp index bdc3c0889f..f98e7a3a0b 100644 --- a/EKF/ekf.cpp +++ b/EKF/ekf.cpp @@ -237,12 +237,7 @@ bool Ekf::update() } // We don't have valid data to output until tilt and yaw alignment is complete - if (_control_status.flags.tilt_align && _control_status.flags.yaw_align) { - return true; - - } else { - return false; - } + return _control_status.flags.tilt_align && _control_status.flags.yaw_align; } bool Ekf::initialiseFilter() diff --git a/EKF/gps_checks.cpp b/EKF/gps_checks.cpp index 952987879c..29d83281f7 100644 --- a/EKF/gps_checks.cpp +++ b/EKF/gps_checks.cpp @@ -98,12 +98,7 @@ bool Ekf::collect_gps(uint64_t time_usec, struct gps_message *gps) } // start collecting GPS if there is a 3D fix and the NED origin has been set - if (_NED_origin_initialised && gps->fix_type >= 3) { - return true; - - } else { - return false; - } + return _NED_origin_initialised && (gps->fix_type >= 3); return false; } @@ -239,10 +234,6 @@ bool Ekf::gps_is_good(struct gps_message *gps) } // continuous period without fail of 10 seconds required to return a healthy status - if (_time_last_imu - _last_gps_fail_us > 1e7) { - return true; - } - - return false; + return (_time_last_imu - _last_gps_fail_us > 1e7); } diff --git a/EKF/terrain_estimator.cpp b/EKF/terrain_estimator.cpp index 7c91cf9262..b337005174 100644 --- a/EKF/terrain_estimator.cpp +++ b/EKF/terrain_estimator.cpp @@ -138,12 +138,7 @@ bool Ekf::get_terrain_vert_pos(float *ret) // The height is useful if the uncertainty in terrain height is significantly smaller than than the estimated height above terrain bool accuracy_useful = (sqrtf(_terrain_var) < 0.2f * fmaxf((_terrain_vpos - _state.pos(2)), _params.rng_gnd_clearance)); - if (_time_last_imu - _time_last_hagl_fuse < 1e6 || accuracy_useful) { - return true; - - } else { - return false; - } + return (_time_last_imu - _time_last_hagl_fuse < 1e6) || accuracy_useful; } void Ekf::get_hagl_innov(float *hagl_innov)