diff --git a/Meter.c b/Meter.c index 1063c40db..5b2784dcd 100644 --- a/Meter.c +++ b/Meter.c @@ -300,7 +300,7 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { memmove(data->values + (data->nValues - oldNValues), data->values, oldNValues * sizeof(*data->values)); memset(data->values, 0, (data->nValues - oldNValues) * sizeof(*data->values)); } - const int nValues = data->nValues; + const size_t nValues = data->nValues; const char* const* GraphMeterMode_dots; int GraphMeterMode_pixPerRow; @@ -327,18 +327,20 @@ static void GraphMeterMode_draw(Meter* this, int x, int y, int w) { struct timeval delay = { .tv_sec = globalDelay / 10, .tv_usec = (globalDelay % 10) * 100000L }; timeradd(&host->realtime, &delay, &(data->time)); - for (int i = 0; i < nValues - 1; i++) + for (size_t i = 0; i < nValues - 1; i++) data->values[i] = data->values[i + 1]; data->values[nValues - 1] = sumPositiveValues(this->values, this->curItems); } - int i = nValues - (w * 2), k = 0; + assert(nValues <= SSIZE_MAX); + ssize_t i = (ssize_t)nValues - (w * 2); + ssize_t k = 0; if (i < 0) { k = -i / 2; i = 0; } - for (; i < nValues - 1; i += 2, k++) { + for (; i < (ssize_t)nValues - 1; i += 2, k++) { int pix = GraphMeterMode_pixPerRow * GRAPH_HEIGHT; if (this->total < 1) this->total = 1;