summaryrefslogtreecommitdiffstats
path: root/Meter.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-11-24 19:34:27 +0100
committerBenny Baumann <BenBE@geshi.org>2020-12-06 16:03:44 +0100
commitad764ff972082608604634c84e5427e7bfdcda1a (patch)
tree3b4cb72205d708563bd9baf62ef2039dc8bafdac /Meter.c
parent77ec86aff4314afd893baed0d16d7bd52c387fd4 (diff)
Introduce METER_BUFFER_CHECK and METER_BUFFER_APPEND_CHR to cleanup writing to bar buffers
Closes: #294
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Meter.c b/Meter.c
index 9c9a8dea..945911c9 100644
--- a/Meter.c
+++ b/Meter.c
@@ -155,7 +155,7 @@ ListItem* Meter_toListItem(Meter* this, bool moving) {
static void TextMeterMode_draw(Meter* this, int x, int y, int w) {
char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, METER_BUFFER_LEN - 1);
+ Meter_updateValues(this, buffer, sizeof(buffer));
(void) w;
attrset(CRT_colors[METER_TEXT]);
@@ -175,7 +175,7 @@ static const char BarMeterMode_characters[] = "|#*@$%&.";
static void BarMeterMode_draw(Meter* this, int x, int y, int w) {
char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, METER_BUFFER_LEN - 1);
+ Meter_updateValues(this, buffer, sizeof(buffer));
w -= 2;
attrset(CRT_colors[METER_TEXT]);
@@ -309,8 +309,8 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) {
for (int i = 0; i < nValues - 1; i++)
data->values[i] = data->values[i + 1];
- char buffer[nValues];
- Meter_updateValues(this, buffer, nValues - 1);
+ char buffer[METER_BUFFER_LEN];
+ Meter_updateValues(this, buffer, sizeof(buffer));
double value = 0.0;
for (uint8_t i = 0; i < this->curItems; i++)
@@ -378,7 +378,7 @@ static void LEDMeterMode_draw(Meter* this, int x, int y, int w) {
LEDMeterMode_digits = LEDMeterMode_digitsAscii;
char buffer[METER_BUFFER_LEN];
- Meter_updateValues(this, buffer, METER_BUFFER_LEN - 1);
+ Meter_updateValues(this, buffer, sizeof(buffer));
RichString_begin(out);
Meter_displayBuffer(this, buffer, &out);

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