summaryrefslogtreecommitdiffstats
path: root/Meter.c
diff options
context:
space:
mode:
authorExplorer09 <explorer09@gmail.com>2023-08-26 15:55:02 +0800
committercgzones <cgzones@googlemail.com>2023-08-29 21:47:56 +0200
commit8ecdb75d74c393895c68be7a311db959b1f373e9 (patch)
treea230f3722c090b22da65b2dfea850d2e2d42f74a /Meter.c
parenta4debfe55045aacdff96807b697fa8771946a7ff (diff)
Explicitly ignore NaN values in BarMeterMode_draw()
Do not throw FP exceptions if any value in a Meter object is a NaN. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Meter.c b/Meter.c
index 27e4cd0c..5991a9c9 100644
--- a/Meter.c
+++ b/Meter.c
@@ -225,8 +225,9 @@ static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
int offset = 0;
for (uint8_t i = 0; i < this->curItems; i++) {
double value = this->values[i];
- value = CLAMP(value, 0.0, this->total);
- if (value > 0) {
+ if (isPositive(value)) {
+ assert(this->total > 0.0);
+ value = MINIMUM(value, this->total);
blockSizes[i] = ceil((value / this->total) * w);
} else {
blockSizes[i] = 0;

© 2014-2024 Faster IT GmbH | imprint | privacy policy