summaryrefslogtreecommitdiffstats
path: root/Meter.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-12-07 11:41:22 +1100
committerNathan Scott <nathans@redhat.com>2020-12-07 11:41:22 +1100
commitb92cfa7d7ac09b4e8a3c377496edd49228221f72 (patch)
treeaefa244b8140e21e2d02018e57c7b9fa0c7d23ec /Meter.c
parent57d9ecc5519a44d4d08f1739ab4b741ccfc2d35a (diff)
parentad764ff972082608604634c84e5427e7bfdcda1a (diff)
Merge branch 'conversion' of https://github.com/cgzones/htop into cgzones-conversion
Diffstat (limited to 'Meter.c')
-rw-r--r--Meter.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/Meter.c b/Meter.c
index 71457d4d..945911c9 100644
--- a/Meter.c
+++ b/Meter.c
@@ -49,7 +49,7 @@ Meter* Meter_new(const struct ProcessList_* pl, int param, const MeterClass* typ
return this;
}
-int Meter_humanUnit(char* buffer, unsigned long int value, int size) {
+int Meter_humanUnit(char* buffer, unsigned long int value, size_t size) {
const char* prefix = "KMGTPEZY";
unsigned long int powi = 1;
unsigned int powj = 1, precision = 2;
@@ -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);
@@ -441,8 +441,7 @@ const MeterMode* const Meter_modes[] = {
/* Blank meter */
-static void BlankMeter_updateValues(Meter* this, char* buffer, int size) {
- (void) this; (void) buffer; (void) size;
+static void BlankMeter_updateValues(ATTR_UNUSED Meter* this, char* buffer, size_t size) {
if (size > 0) {
*buffer = 0;
}

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