Clean up many warnings. add clang_strict target to help uncover warnings

This commit is contained in:
Mark VanderVoord
2014-05-22 13:43:52 -04:00
parent 1cf02f8bf3
commit fe2c691e9d
3 changed files with 184 additions and 101 deletions

View File

@ -92,7 +92,7 @@ void UnityPrint(const char* string)
else else
{ {
UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('\\');
UnityPrintNumberHex((_U_SINT)*pch, 2); UnityPrintNumberHex((_U_UINT)*pch, 2);
} }
pch++; pch++;
} }
@ -112,7 +112,7 @@ void UnityPrintNumberByStyle(const _U_SINT number, const UNITY_DISPLAY_STYLE_T s
} }
else 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; UNITY_PRINT_EOL;
UnityPrint(file); UnityPrint(file);
UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(':');
UnityPrintNumber(line); UnityPrintNumber((_U_SINT)line);
UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(':');
UnityPrint(Unity.CurrentTestName); UnityPrint(Unity.CurrentTestName);
UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(':');
@ -372,9 +372,9 @@ void UnityAssertBits(const _U_SINT mask,
{ {
UnityTestResultsFailBegin(lineNumber); UnityTestResultsFailBegin(lineNumber);
UnityPrint(UnityStrExpected); UnityPrint(UnityStrExpected);
UnityPrintMask(mask, expected); UnityPrintMask((_U_UINT)mask, (_U_UINT)expected);
UnityPrint(UnityStrWas); UnityPrint(UnityStrWas);
UnityPrintMask(mask, actual); UnityPrintMask((_U_UINT)mask, (_U_UINT)actual);
UnityAddMsgIfSpecified(msg); UnityAddMsgIfSpecified(msg);
UNITY_FAIL_AND_BAIL; 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 // 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 // as UNITY_DISPLAY_STYLE_INT includes a flag for UNITY_DISPLAY_RANGE_AUTO, which the width-specific
// variants do not. Therefore remove this flag. // 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_HEX8:
case UNITY_DISPLAY_STYLE_INT8: case UNITY_DISPLAY_STYLE_INT8:
@ -1098,7 +1098,7 @@ void tearDown(void);
void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum)
{ {
Unity.CurrentTestName = FuncName; Unity.CurrentTestName = FuncName;
Unity.CurrentTestLineNumber = FuncLineNum; Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum;
Unity.NumberOfTests++; Unity.NumberOfTests++;
if (TEST_PROTECT()) if (TEST_PROTECT())
{ {
@ -1130,11 +1130,11 @@ int UnityEnd(void)
{ {
UnityPrint("-----------------------"); UnityPrint("-----------------------");
UNITY_PRINT_EOL; UNITY_PRINT_EOL;
UnityPrintNumber(Unity.NumberOfTests); UnityPrintNumber((_U_SINT)(Unity.NumberOfTests));
UnityPrint(" Tests "); UnityPrint(" Tests ");
UnityPrintNumber(Unity.TestFailures); UnityPrintNumber((_U_SINT)(Unity.TestFailures));
UnityPrint(" Failures "); UnityPrint(" Failures ");
UnityPrintNumber(Unity.TestIgnores); UnityPrintNumber((_U_SINT)(Unity.TestIgnores));
UnityPrint(" Ignored"); UnityPrint(" Ignored");
UNITY_PRINT_EOL; UNITY_PRINT_EOL;
if (Unity.TestFailures == 0U) if (Unity.TestFailures == 0U)
@ -1146,5 +1146,5 @@ int UnityEnd(void)
UnityPrintFail(); UnityPrintFail();
} }
UNITY_PRINT_EOL; UNITY_PRINT_EOL;
return Unity.TestFailures; return (int)(Unity.TestFailures);
} }

83
targets/clang_strict.yml Normal file
View 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: []

View File

@ -62,7 +62,7 @@ void testUnitySizeInitializationReminder(void)
/* This test ensures that sizeof(struct _Unity) doesn't change. If this /* This test ensures that sizeof(struct _Unity) doesn't change. If this
* test breaks, go look at the initialization of the Unity global variable * 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. */ * 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 " "the initialization of the Unity symbol in unity.c is "
"still correct."; "still correct.";
@ -151,7 +151,7 @@ void testFail(void)
void testIsNull(void) void testIsNull(void)
{ {
char* ptr1 = NULL; char* ptr1 = NULL;
char* ptr2 = "hello"; const char* ptr2 = "hello";
TEST_ASSERT_NULL(ptr1); TEST_ASSERT_NULL(ptr1);
TEST_ASSERT_NOT_NULL(ptr2); TEST_ASSERT_NOT_NULL(ptr2);
@ -159,7 +159,7 @@ void testIsNull(void)
void testIsNullShouldFailIfNot(void) void testIsNullShouldFailIfNot(void)
{ {
char* ptr1 = "hello"; const char* ptr1 = "hello";
EXPECT_ABORT_BEGIN EXPECT_ABORT_BEGIN
TEST_ASSERT_NULL(ptr1); TEST_ASSERT_NULL(ptr1);
@ -1940,8 +1940,8 @@ void testEqualInt64s(void)
_US64 v0, v1; _US64 v0, v1;
_US64 *p0, *p1; _US64 *p0, *p1;
v0 = 0x9876543201234567; v0 = (_US64)0x9876543201234567;
v1 = 0x9876543201234567; v1 = (_US64)0x9876543201234567;
p0 = &v0; p0 = &v0;
p1 = &v1; p1 = &v1;