Merge pull request #170 from jsalling/feature/fix-compiler-warnings

Clean up int conversion warnings in Fixture
This commit is contained in:
Mark VanderVoord
2016-02-23 06:38:57 -05:00
5 changed files with 45 additions and 24 deletions

View File

@ -23,9 +23,9 @@ void tearDown(void) { /*does nothing*/ }
static void announceTestRun(unsigned int runNumber) static void announceTestRun(unsigned int runNumber)
{ {
UnityPrint("Unity test run "); UnityPrint("Unity test run ");
UnityPrintNumber(runNumber+1); UnityPrintNumberUnsigned(runNumber+1);
UnityPrint(" of "); UnityPrint(" of ");
UnityPrintNumber(UnityFixture.RepeatCount); UnityPrintNumberUnsigned(UnityFixture.RepeatCount);
UNITY_PRINT_EOL(); UNITY_PRINT_EOL();
} }
@ -45,7 +45,7 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void))
UnityEnd(); UnityEnd();
} }
return Unity.TestFailures; return (int)Unity.TestFailures;
} }
static int selected(const char* filter, const char* name) static int selected(const char* filter, const char* name)
@ -71,7 +71,7 @@ void UnityTestRunner(unityfunction* setup,
const char* printableName, const char* printableName,
const char* group, const char* group,
const char* name, const char* name,
const char* file, int line) const char* file, unsigned int line)
{ {
if (testSelected(name) && groupSelected(group)) if (testSelected(name) && groupSelected(group))
{ {

View File

@ -23,7 +23,7 @@ void UnityTestRunner(unityfunction* setup,
const char* printableName, const char* printableName,
const char* group, const char* group,
const char* name, const char* name,
const char* file, int line); const char* file, unsigned int line);
void UnityIgnoreTest(const char* printableName, const char* group, const char* name); void UnityIgnoreTest(const char* printableName, const char* group, const char* name);
void UnityMalloc_StartTest(void); void UnityMalloc_StartTest(void);

View File

@ -1,8 +1,11 @@
CC = gcc CC = gcc
CFLAGS += -Werror #DEBUG = -O0 -g
CFLAGS += -std=c99 CFLAGS += -std=c99
CFLAGS += -pedantic CFLAGS += -pedantic
CFLAGS += -Wundef CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Werror
CFLAGS += $(DEBUG)
DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
SRC = ../src/unity_fixture.c \ SRC = ../src/unity_fixture.c \
../../../src/unity.c \ ../../../src/unity.c \
@ -32,7 +35,26 @@ noStdlibMalloc: ../build/
./$(TARGET) ./$(TARGET)
clangEverything: clangEverything:
$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m64 -Weverything # || true #prevents make from failing clang $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m64 -Weverything
../build : ../build :
mkdir -p ../build mkdir -p ../build
clean:
rm -f $(TARGET)
# These extended flags DO get included before any target build runs
CFLAGS += -Wbad-function-cast
CFLAGS += -Wcast-qual
CFLAGS += -Wconversion
CFLAGS += -Wformat=2
CFLAGS += -Wmissing-prototypes
CFLAGS += -Wold-style-definition
CFLAGS += -Wpointer-arith
CFLAGS += -Wshadow
CFLAGS += -Wstrict-overflow=5
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wswitch-default
CFLAGS += -Wundef
CFLAGS += -Wunused
CFLAGS += -fstrict-aliasing

View File

@ -22,14 +22,13 @@ TEST_TEAR_DOWN(UnityFixture)
{ {
} }
int my_int; static int* pointer1 = 0;
int* pointer1 = 0; static int* pointer2 = (int*)2;
int* pointer2 = (int*)2; static int* pointer3 = (int*)3;
int* pointer3 = (int*)3; static int int1;
int int1; static int int2;
int int2; static int int3;
int int3; static int int4;
int int4;
TEST(UnityFixture, PointerSetting) TEST(UnityFixture, PointerSetting)
{ {
@ -112,8 +111,8 @@ TEST(UnityFixture, CallocFillsWithZero)
free(m); free(m);
} }
char *p1; static char *p1;
char *p2; static char *p2;
TEST(UnityFixture, PointerSet) TEST(UnityFixture, PointerSet)
{ {
@ -143,10 +142,10 @@ TEST(UnityFixture, FreeNULLSafety)
TEST_GROUP(UnityCommandOptions); TEST_GROUP(UnityCommandOptions);
int savedVerbose; static int savedVerbose;
int savedRepeat; static unsigned int savedRepeat;
const char* savedName; static const char* savedName;
const char* savedGroup; static const char* savedGroup;
TEST_SETUP(UnityCommandOptions) TEST_SETUP(UnityCommandOptions)
{ {

View File

@ -22,7 +22,7 @@ void UnityOutputCharSpy_Create(int s)
size = s; size = s;
count = 0; count = 0;
spy_enable = 0; spy_enable = 0;
buffer = malloc(size); buffer = malloc((size_t)size);
TEST_ASSERT_NOT_NULL_MESSAGE(buffer, "Internal malloc failed in Spy Create():" __FILE__); TEST_ASSERT_NOT_NULL_MESSAGE(buffer, "Internal malloc failed in Spy Create():" __FILE__);
memset(buffer, 0, size); memset(buffer, 0, size);
} }
@ -38,7 +38,7 @@ int UnityOutputCharSpy_OutputChar(int c)
if (spy_enable) if (spy_enable)
{ {
if (count < (size-1)) if (count < (size-1))
buffer[count++] = c; buffer[count++] = (char)c;
} }
else else
{ {