From 63477fc09616b5f7df0af17dd5d990a760ba2ae4 Mon Sep 17 00:00:00 2001 From: Reinhold Gschweicher Date: Mon, 13 Sep 2021 22:33:21 +0200 Subject: Fix unsigned/signed comparison warning in Metronome.cpp `xTaskGetTickCount()` returns a `TickType_t`, which is defined as an `uint32_t`. This is compared to the `bpm` variable, which is a `int16_t` in the range of 40 to 220 as defined in the constructor. ```cpp lv_arc_set_range(bpmArc, 40, 220); ``` Just assume that `bpm` is greater than 0, as this would result in a divison by zero or negative values, which would unintentionally underflow to a very large number. --- src/displayapp/screens/Metronome.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/displayapp') diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 884a4a51..52cb8519 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -78,7 +78,7 @@ Metronome::~Metronome() { void Metronome::Refresh() { if (metronomeStarted) { - if (xTaskGetTickCount() - startTime > 60 * configTICK_RATE_HZ / bpm) { + if (xTaskGetTickCount() - startTime > 60u * configTICK_RATE_HZ / static_cast(bpm)) { startTime += 60 * configTICK_RATE_HZ / bpm; counter--; if (counter == 0) { -- cgit v1.2.3