From 3588e5b6d3a282391fc253cc7ca02a096e153983 Mon Sep 17 00:00:00 2001 From: Crt Mori Date: Tue, 24 Jan 2017 22:52:43 +0100 Subject: [PATCH] Aligning definition and declaration of UnityPrintFloat There was a mismatch of definition and declaration of UnityPrintFloat and this commit aligns both on const UNITY_DOUBLE, but then inside it actually uses a positive version of the variable only. --- src/unity.c | 11 ++++++++--- src/unity_internals.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/unity.c b/src/unity.c index 91589e8..54a3452 100644 --- a/src/unity.c +++ b/src/unity.c @@ -269,12 +269,17 @@ static void UnityPrintDecimalAndNumberWithLeadingZeros(UNITY_INT32 fraction_part * else snprintf(buf, sizeof buf, "%.6f", number); * UnityPrint(buf); */ -void UnityPrintFloat(UNITY_DOUBLE number) +void UnityPrintFloat(const UNITY_DOUBLE input_number) { - if (number < 0) + UNITY_DOUBLE number; + + if (input_number < 0) { UNITY_OUTPUT_CHAR('-'); - number = -number; + number = -input_number; + } else + { + number = input_number; } if (isnan(number)) UnityPrint(UnityStrNaN); diff --git a/src/unity_internals.h b/src/unity_internals.h index e9fef63..bdcee92 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -427,7 +427,7 @@ void UnityPrintNumberUnsigned(const UNITY_UINT number); void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles); #ifndef UNITY_EXCLUDE_FLOAT_PRINT -void UnityPrintFloat(const UNITY_DOUBLE number); +void UnityPrintFloat(const UNITY_DOUBLE input_number); #endif /*------------------------------------------------------- -- GitLab