Skip to content

Commit fe8d1e9

Browse files
authored
Merge pull request #792 from RossSmyth/errors
Fix up some warnings/errors
2 parents fa03368 + 12705bf commit fe8d1e9

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

test/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ CC = clang
1010
endif
1111
ifeq ($(findstring clang, $(CC)), clang)
1212
E = -Weverything
13-
CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes
14-
CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn
13+
CFLAGS += $E -Wno-unknown-warning-option
14+
CFLAGS += -Wno-unsafe-buffer-usage
1515
endif
1616
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
1717
#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros
1818
CFLAGS += -Wno-switch-enum -Wno-double-promotion
19-
CFLAGS += -Wno-poison-system-directories
2019
CFLAGS += -Wno-covered-switch-default
2120
CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \
2221
-Wstrict-prototypes -Wswitch-default -Wundef

test/tests/self_assessment_utils.h

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ static char putcharSpyBuffer[SPY_BUFFER_MAX];
7272
static UNITY_COUNTER_TYPE indexSpyBuffer;
7373
static UNITY_COUNTER_TYPE putcharSpyEnabled;
7474

75+
#ifdef __clang__
76+
#pragma clang diagnostic push
77+
#pragma clang diagnostic ignored "-Wmissing-prototypes"
78+
#endif
79+
7580
void startPutcharSpy(void)
7681
{
7782
indexSpyBuffer = 0;
@@ -133,19 +138,30 @@ void flushSpy(void)
133138
if (flushSpyEnabled){ flushSpyCalls++; }
134139
}
135140

136-
#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \
141+
#ifdef __clang__
142+
#pragma clang diagnostic pop
143+
#endif
144+
145+
#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) do { \
137146
startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \
138147
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
139-
}
148+
} while (0)
140149

141-
#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \
150+
#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) do { \
142151
startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \
143152
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
144-
}
153+
} while (0)
145154

146-
#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \
155+
#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) do { \
147156
startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \
148157
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
149-
}
158+
} while (0)
159+
160+
#endif
150161

162+
// The reason this isn't folded into the above diagnostic is to semi-isolate
163+
// the header contents from the user content it is included into.
164+
#ifdef __clang__
165+
#pragma clang diagnostic push
166+
#pragma clang diagnostic ignored "-Wmissing-prototypes"
151167
#endif

test/tests/test_unity_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void testUnitySizeInitializationReminder(void)
6161
#ifndef UNITY_EXCLUDE_SETJMP_H
6262
jmp_buf AbortFrame;
6363
#endif
64-
} _Expected_Unity;
64+
} Expected_Unity;
6565
#else
6666
struct {
6767
const char* TestFile;
@@ -81,30 +81,30 @@ void testUnitySizeInitializationReminder(void)
8181
#ifndef UNITY_EXCLUDE_SETJMP_H
8282
jmp_buf AbortFrame;
8383
#endif
84-
} _Expected_Unity;
84+
} Expected_Unity;
8585
#endif
8686

8787
/* Compare our fake structure's size to the actual structure's size. They
8888
* should be the same.
8989
*
9090
* This accounts for alignment, padding, and packing issues that might come
9191
* up between different architectures. */
92-
TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message);
92+
TEST_ASSERT_EQUAL_MESSAGE(sizeof(Expected_Unity), sizeof(Unity), message);
9393
}
9494

95-
void testPassShouldEndImmediatelyWithPass(void)
95+
UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPass(void)
9696
{
9797
TEST_PASS();
9898
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
9999
}
100100

101-
void testPassShouldEndImmediatelyWithPassAndMessage(void)
101+
UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPassAndMessage(void)
102102
{
103103
TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!");
104104
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
105105
}
106106

107-
void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void)
107+
UNITY_FUNCTION_ATTR(noreturn) void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void)
108108
{
109109
TEST_MESSAGE("This is just a message");
110110
TEST_MESSAGE("This is another message");
@@ -282,7 +282,7 @@ void testProtection(void)
282282
TEST_ASSERT_EQUAL(3, mask);
283283
}
284284

285-
void testIgnoredAndThenFailInTearDown(void)
285+
UNITY_FUNCTION_ATTR(noreturn) void testIgnoredAndThenFailInTearDown(void)
286286
{
287287
SetToOneToFailInTearDown = 1;
288288
TEST_IGNORE();

test/tests/test_unity_floats.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,9 @@ void testNotEqualFloatEachEqualLengthZero(void)
12081208
#endif
12091209
}
12101210

1211+
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
1212+
UNITY_FUNCTION_ATTR(noreturn)
1213+
#endif
12111214
void testFloatPrinting(void)
12121215
{
12131216
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
@@ -1257,6 +1260,9 @@ void testFloatPrinting(void)
12571260
#endif
12581261
}
12591262

1263+
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
1264+
UNITY_FUNCTION_ATTR(noreturn)
1265+
#endif
12601266
void testFloatPrintingRoundTiesToEven(void)
12611267
{
12621268
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
@@ -1368,6 +1374,9 @@ static void printFloatValue(float f)
13681374
#endif
13691375
#endif
13701376

1377+
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
1378+
UNITY_FUNCTION_ATTR(noreturn)
1379+
#endif
13711380
void testFloatPrintingRandomSamples(void)
13721381
{
13731382
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)

0 commit comments

Comments
 (0)