Remove "error: assuming signed overflow does not occur when reducing constant in comparison [-Werror=strict-overflow]"

This commit is contained in:
Fabian Zahn
2021-02-27 10:49:34 +01:00
parent 7edf9d9ac5
commit fa32e530ba

View File

@@ -369,10 +369,12 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
} }
else else
{ {
UNITY_INT32 n_int = 0, n; UNITY_INT32 n_int = 0;
int exponent = 0; UNITY_INT32 n;
int decimals, digits; int exponent = 0;
char buf[16] = {0}; int decimals;
int digits;
char buf[16] = {0};
/* /*
* Scale up or down by powers of 10. To minimize rounding error, * Scale up or down by powers of 10. To minimize rounding error,
@@ -445,14 +447,19 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
/* build up buffer in reverse order */ /* build up buffer in reverse order */
digits = 0; digits = 0;
while ((n != 0) || (digits < (decimals + 1))) while ((n != 0) || (digits <= decimals))
{ {
buf[digits++] = (char)('0' + n % 10); buf[digits++] = (char)('0' + n % 10);
n /= 10; n /= 10;
} }
/* print out buffer (backwards) */
while (digits > 0) while (digits > 0)
{ {
if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); } if (digits == decimals)
{
UNITY_OUTPUT_CHAR('.');
}
UNITY_OUTPUT_CHAR(buf[--digits]); UNITY_OUTPUT_CHAR(buf[--digits]);
} }