Warning messages in Unity - theolind/mahm3lib GitHub Wiki
The "original" Unity file 'unity.c' is infested with some nasty code which generates warning messages. Here are the problems, both solved and remaining:
Conversion to 'XXX' from 'YYY' may change the sign of the result
Implicit type conversion. Consider this line of code as an example:
return Unity.TestFailures;
Just implement explicit type conversion. Consider this line of code as an example:
return (int)Unity.TestFailures;
"braces around scalar initializer [enabled by default]"
"(near initialization for 'Unity.AbortFrame[0]') [enabled by default]"
Initialization of global variable 'Unity'.
struct _Unity Unity = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , {{{ 0 }}} };
Corrected the code by first studying the definition of the struct, then changed code.
struct _Unity Unity = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , { 0 } };
"no previous prototype for 'UnityTestResultsFailBegin' [-Wmissing-prototypes]"
Functions were missing prototypes.
Since the functions scope are only within 'unity.c', I declared them as static.
"comparing floating point with == or != is unsafe [-Wfloat-equal]"
Four of the expressions are identical.
if ((diff * 0.0f != 0.0f) || (diff > tol))
Since the purpose of this expression
(diff * 0.0f != 0.0f)
is to check if the result of the multiplikation isn't equal to zero, lets rewrite it to:
((diff * 0.0f < 0.0f) || (diff * 0.0f > 0.0f))
One of the expressions looks like:
if (actual == actual)
The purpose of the expression is to verify equivalance, which also can be expressed like this:
if (!((actual < actual) || (actual > actual)))