mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-20 05:50:29 +08:00
Clean up many warnings. add clang_strict target to help uncover warnings
This commit is contained in:
22
src/unity.c
22
src/unity.c
@ -92,7 +92,7 @@ void UnityPrint(const char* string)
|
||||
else
|
||||
{
|
||||
UNITY_OUTPUT_CHAR('\\');
|
||||
UnityPrintNumberHex((_U_SINT)*pch, 2);
|
||||
UnityPrintNumberHex((_U_UINT)*pch, 2);
|
||||
}
|
||||
pch++;
|
||||
}
|
||||
@ -112,7 +112,7 @@ void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T s
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityPrintNumberHex((_U_UINT)number, (style & 0x000F) << 1);
|
||||
UnityPrintNumberHex((_U_UINT)number, (char)((style & 0x000F) << 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
||||
UNITY_PRINT_EOL;
|
||||
UnityPrint(file);
|
||||
UNITY_OUTPUT_CHAR(':');
|
||||
UnityPrintNumber(line);
|
||||
UnityPrintNumber((_U_SINT)line);
|
||||
UNITY_OUTPUT_CHAR(':');
|
||||
UnityPrint(Unity.CurrentTestName);
|
||||
UNITY_OUTPUT_CHAR(':');
|
||||
@ -372,9 +372,9 @@ void UnityAssertBits(const _U_SINT mask,
|
||||
{
|
||||
UnityTestResultsFailBegin(lineNumber);
|
||||
UnityPrint(UnityStrExpected);
|
||||
UnityPrintMask(mask, expected);
|
||||
UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
|
||||
UnityPrint(UnityStrWas);
|
||||
UnityPrintMask(mask, actual);
|
||||
UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
|
||||
UnityAddMsgIfSpecified(msg);
|
||||
UNITY_FAIL_AND_BAIL;
|
||||
}
|
||||
@ -429,7 +429,7 @@ void UnityAssertEqualIntArray(UNITY_PTR_ATTRIBUTE const void* expected,
|
||||
// If style is UNITY_DISPLAY_STYLE_INT, we'll fall into the default case rather than the INT16 or INT32 (etc) case
|
||||
// as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
|
||||
// variants do not. Therefore remove this flag.
|
||||
switch(style & ~UNITY_DISPLAY_RANGE_AUTO)
|
||||
switch(style & (UNITY_DISPLAY_STYLE_T)(~UNITY_DISPLAY_RANGE_AUTO))
|
||||
{
|
||||
case UNITY_DISPLAY_STYLE_HEX8:
|
||||
case UNITY_DISPLAY_STYLE_INT8:
|
||||
@ -1098,7 +1098,7 @@ void tearDown(void);
|
||||
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
|
||||
{
|
||||
Unity.CurrentTestName = FuncName;
|
||||
Unity.CurrentTestLineNumber = FuncLineNum;
|
||||
Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
|
||||
Unity.NumberOfTests++;
|
||||
if (TEST_PROTECT())
|
||||
{
|
||||
@ -1130,11 +1130,11 @@ int UnityEnd(void)
|
||||
{
|
||||
UnityPrint("-----------------------");
|
||||
UNITY_PRINT_EOL;
|
||||
UnityPrintNumber(Unity.NumberOfTests);
|
||||
UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
|
||||
UnityPrint(" Tests ");
|
||||
UnityPrintNumber(Unity.TestFailures);
|
||||
UnityPrintNumber((_U_SINT)(Unity.TestFailures));
|
||||
UnityPrint(" Failures ");
|
||||
UnityPrintNumber(Unity.TestIgnores);
|
||||
UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
|
||||
UnityPrint(" Ignored");
|
||||
UNITY_PRINT_EOL;
|
||||
if (Unity.TestFailures == 0U)
|
||||
@ -1146,5 +1146,5 @@ int UnityEnd(void)
|
||||
UnityPrintFail();
|
||||
}
|
||||
UNITY_PRINT_EOL;
|
||||
return Unity.TestFailures;
|
||||
return (int)(Unity.TestFailures);
|
||||
}
|
||||
|
83
targets/clang_strict.yml
Normal file
83
targets/clang_strict.yml
Normal file
@ -0,0 +1,83 @@
|
||||
---
|
||||
compiler:
|
||||
path: clang
|
||||
source_path: 'src/'
|
||||
unit_tests_path: &unit_tests_path 'test/'
|
||||
build_path: &build_path 'build/'
|
||||
options:
|
||||
- '-c'
|
||||
- '-Wall'
|
||||
- '-Wextra'
|
||||
- '-Werror'
|
||||
- '-Wcast-qual'
|
||||
- '-Wconversion'
|
||||
- '-Wdisabled-optimization'
|
||||
- '-Wformat=2'
|
||||
- '-Winit-self'
|
||||
- '-Winline'
|
||||
- '-Winvalid-pch'
|
||||
- '-Wmissing-declarations'
|
||||
- '-Wmissing-include-dirs'
|
||||
- '-Wmissing-prototypes'
|
||||
- '-Wnonnull'
|
||||
- '-Wpacked'
|
||||
- '-Wpointer-arith'
|
||||
- '-Wredundant-decls'
|
||||
- '-Wswitch-default'
|
||||
- '-Wstrict-aliasing'
|
||||
- '-Wstrict-overflow=5'
|
||||
- '-Wuninitialized'
|
||||
- '-Wunused'
|
||||
- '-Wunreachable-code'
|
||||
- '-Wreturn-type'
|
||||
- '-Wshadow'
|
||||
- '-Wundef'
|
||||
- '-Wwrite-strings'
|
||||
- '-Wno-missing-declarations'
|
||||
- '-Wno-missing-prototypes'
|
||||
- '-Wno-nested-externs'
|
||||
- '-Wno-redundant-decls'
|
||||
- '-Wno-unused-parameter'
|
||||
- '-Wno-variadic-macros'
|
||||
- '-Wbad-function-cast'
|
||||
- '-fms-extensions'
|
||||
- '-fno-omit-frame-pointer'
|
||||
- '-ffloat-store'
|
||||
- '-fno-common'
|
||||
- '-fstrict-aliasing'
|
||||
- '-std=gnu99'
|
||||
- '-pedantic'
|
||||
- '-O0'
|
||||
includes:
|
||||
prefix: '-I'
|
||||
items:
|
||||
- 'src/'
|
||||
- '../src/'
|
||||
- *unit_tests_path
|
||||
defines:
|
||||
prefix: '-D'
|
||||
items:
|
||||
- UNITY_INCLUDE_DOUBLE
|
||||
- UNITY_SUPPORT_TEST_CASES
|
||||
- UNITY_SUPPORT_64
|
||||
object_files:
|
||||
prefix: '-o'
|
||||
extension: '.o'
|
||||
destination: *build_path
|
||||
linker:
|
||||
path: gcc
|
||||
options:
|
||||
- -lm
|
||||
- '-m64'
|
||||
includes:
|
||||
prefix: '-I'
|
||||
object_files:
|
||||
path: *build_path
|
||||
extension: '.o'
|
||||
bin_files:
|
||||
prefix: '-o'
|
||||
extension: '.exe'
|
||||
destination: *build_path
|
||||
colour: true
|
||||
:unity:
|
||||
:plugins: []
|
@ -62,7 +62,7 @@ void testUnitySizeInitializationReminder(void)
|
||||
/* This test ensures that sizeof(struct _Unity) doesn't change. If this
|
||||
* test breaks, go look at the initialization of the Unity global variable
|
||||
* in unity.c and make sure we're filling in the proper fields. */
|
||||
char * message = "Unexpected size for _Unity struct. Please check that "
|
||||
const char* message = "Unexpected size for _Unity struct. Please check that "
|
||||
"the initialization of the Unity symbol in unity.c is "
|
||||
"still correct.";
|
||||
|
||||
@ -151,7 +151,7 @@ void testFail(void)
|
||||
void testIsNull(void)
|
||||
{
|
||||
char* ptr1 = NULL;
|
||||
char* ptr2 = "hello";
|
||||
const char* ptr2 = "hello";
|
||||
|
||||
TEST_ASSERT_NULL(ptr1);
|
||||
TEST_ASSERT_NOT_NULL(ptr2);
|
||||
@ -159,7 +159,7 @@ void testIsNull(void)
|
||||
|
||||
void testIsNullShouldFailIfNot(void)
|
||||
{
|
||||
char* ptr1 = "hello";
|
||||
const char* ptr1 = "hello";
|
||||
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NULL(ptr1);
|
||||
@ -1940,8 +1940,8 @@ void testEqualInt64s(void)
|
||||
_US64 v0, v1;
|
||||
_US64 *p0, *p1;
|
||||
|
||||
v0 = 0x9876543201234567;
|
||||
v1 = 0x9876543201234567;
|
||||
v0 = (_US64)0x9876543201234567;
|
||||
v1 = (_US64)0x9876543201234567;
|
||||
p0 = &v0;
|
||||
p1 = &v1;
|
||||
|
||||
|
Reference in New Issue
Block a user