The high/low bits masks for TEST_ASSERT_BIT(S)_HIGH/LOW are created
by casting 0/-1 to UNITY_UINT32. This isn't OK on 64-bit platforms
as it results in a high bits mask of 0x00000000ffffffff instead of
0xffffffffffffffff.
Cast 0/-1 to UNITY_UINT instead.
GCC (& Clang) have the notion of pure and const functions [1],
where those attributes are intended to help the optimiser.
Annotate a few APIs here with the appropriate key words, which
also fixes Wsuggest-attribute=noreturn warning, which a
source base might have enabled:
Compiling unity.c...
.../src/unity.c: In function ‘UnityFail’:
.../src/unity.c:1759:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
1759 | void UnityFail(const char* msg, const UNITY_LINE_TYPE line)
| ^~~~~~~~~
.../src/unity.c: In function ‘UnityIgnore’:
.../src/unity.c:1796:6: warning: function might be candidate for attribute ‘noreturn’ [-Wsuggest-attribute=noreturn]
1796 | void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
| ^~~~~~~~~~~
[1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
Signed-off-by: André Draszik <git@andred.net>
Compiling a source base / test with Wswitch-enum enabled, gives
the following warning:
../src/unity.c: In function ‘UnityAssertFloatSpecial’:
../src/unity.c:1092:5: warning: enumeration value ‘UNITY_FLOAT_INVALID_TRAIT’ not handled in switch [-Wswitch-enum]
1092 | switch (style)
| ^~~~~~
Fix by adding the missing value to the default (unhandled) case.
Signed-off-by: André Draszik <git@andred.net>
Compiling a source base / test with Wsign-compare enabled, gives
the following warning:
build/test/runners/test_system_runner.c: In function ‘run_test’:
build/test/runners/test_system_runner.c:62:35: warning: conversion to ‘UNITY_UINT’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
62 | Unity.CurrentTestLineNumber = line_num;
| ^~~~~~~~
Fix by updating the type in the function declaration.
Signed-off-by: André Draszik <git@andred.net>