From a05990c6c7250ba0aaed94e0222b598e0190bad4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 12 Sep 2024 07:01:23 +0200 Subject: Merging upstream version 4.6. Signed-off-by: Daniel Baumann --- tempcomp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tempcomp.c') diff --git a/tempcomp.c b/tempcomp.c index a468e33..4c36367 100644 --- a/tempcomp.c +++ b/tempcomp.c @@ -66,10 +66,9 @@ get_tempcomp(double temp) return k0 + (temp - T0) * k1 + (temp - T0) * (temp - T0) * k2; /* Otherwise interpolate/extrapolate between two nearest points */ - - for (i = 1; i < ARR_GetSize(points); i++) { - p2 = (struct Point *)ARR_GetElement(points, i); - if (p2->temp >= temp) + for (i = 1; ; i++) { + p2 = ARR_GetElement(points, i); + if (p2->temp >= temp || i + 1 >= ARR_GetSize(points)) break; } p1 = p2 - 1; -- cgit v1.2.3