From a9c4868883ae2ac67ac1bd30b94a23c3599644b9 Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Sat, 3 Feb 2024 14:56:06 +0800 Subject: [PATCH] valueCellIndex() return size_t type --- Meter.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Meter.c b/Meter.c index dfe06dc8e..99f516f55 100644 --- a/Meter.c +++ b/Meter.c @@ -321,7 +321,7 @@ static void GraphMeterMode_reallocateGraphBuffer(Meter* this, const GraphDrawCon data->nValues = nValues; } -static unsigned int GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool isPercentChart, int deltaExp, unsigned int y, unsigned int* scaleFactor, unsigned int* increment) { +static size_t GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool isPercentChart, int deltaExp, unsigned int y, unsigned int* scaleFactor, unsigned int* increment) { if (scaleFactor) *scaleFactor = 1; @@ -334,7 +334,7 @@ static unsigned int GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool *increment = 1; if (y > yTop) - return (unsigned int)-1; + return (size_t)-1; return y; } @@ -359,7 +359,7 @@ static unsigned int GraphMeterMode_valueCellIndex(unsigned int graphHeight, bool *increment = 2U << deltaExp; if (y > yTop) - return (unsigned int)-1; + return (size_t)-1; // "b" is the "base" offset or the upper bits of offset unsigned int b = (y * 2) << deltaExp; @@ -600,7 +600,7 @@ static void GraphMeterMode_computeColors(Meter* this, const GraphDrawContext* co assert((unsigned int)numDots <= graphHeight * 8); unsigned int increment; - unsigned int firstCellIndex = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExp, 0, NULL, &increment); + size_t firstCellIndex = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExp, 0, NULL, &increment); assert(firstCellIndex < context->nCellsPerValue); unsigned int topCell = ((unsigned int)numDots - 1) / 8; @@ -913,9 +913,9 @@ static void GraphMeterMode_recordNewValue(Meter* this, const GraphDrawContext* c } // Clear cells - unsigned int i = ((unsigned int)numDots + 8 - 1) / 8; // Round up - i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, 0, i, NULL, NULL); - if (i != (unsigned int)-1) { + unsigned int y = ((unsigned int)numDots + 8 - 1) / 8; // Round up + size_t i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, 0, y, NULL, NULL); + if (i != (size_t)-1) { assert(i < nCellsPerValue); memset(&valueStart[i], 0, (nCellsPerValue - i) * sizeof(*valueStart)); } @@ -1048,8 +1048,8 @@ static int GraphMeterMode_lookupCell(const Meter* this, const GraphDrawContext* int deltaExpArg = deltaExp >= UINT16_WIDTH ? UINT16_WIDTH - 1 : deltaExp; unsigned int scaleFactor; - unsigned int i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExpArg, y, &scaleFactor, NULL); - if (i == (unsigned int)-1) + size_t i = GraphMeterMode_valueCellIndex(graphHeight, isPercentChart, deltaExpArg, y, &scaleFactor, NULL); + if (i == (size_t)-1) goto cellIsEmpty; if (deltaExp >= UINT16_WIDTH) {