From dc96c3e6ddda456d6ed3bbf097213b5aad7f402b Mon Sep 17 00:00:00 2001 From: Erik Flodin Date: Sat, 17 Apr 2021 19:00:06 +0200 Subject: [PATCH] Fix strict-overflow compiler warning By replacing "x < y + 1" with "x <= y" the compiler doesn't have to do it and the warning "assuming signed overflow does not occur when reducing constant in comparison [-Werror=strict-overflow]" is avoided. --- src/unity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unity.c b/src/unity.c index be3528f..764a42b 100644 --- a/src/unity.c +++ b/src/unity.c @@ -445,7 +445,7 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) /* build up buffer in reverse order */ digits = 0; - while ((n != 0) || (digits < (decimals + 1))) + while ((n != 0) || (digits <= decimals)) { buf[digits++] = (char)('0' + n % 10); n /= 10;