Skip to content

Commit bedefe0

Browse files
Fix compilation with -Wpedantic on GCC (#1059)
* Enable -Wpedantic for GCC by default * cmake: add -Wno-pedantic for FreeRTOS_Sockets.c && GCC * Fix warnings with enum eFrameProcessingResult * Fix unit tests * Fix unit tests --------- Co-authored-by: tony-josi-aws <[email protected]>
1 parent 7af0bfe commit bedefe0

File tree

8 files changed

+20
-13
lines changed

8 files changed

+20
-13
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ add_compile_options(
201201
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
202202
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
203203
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
204-
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wpedantic>
204+
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wpedantic>
205205
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wconversion>
206206
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wunused-variable>
207207
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>
@@ -217,6 +217,9 @@ add_compile_options(
217217
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt>
218218
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-noreturn>
219219
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-align>
220+
221+
# Suppressions required to build clean with GCC.
222+
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-declaration-after-statement>
220223
)
221224

222225
########################################################################

source/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ target_include_directories( freertos_plus_tcp SYSTEM
9595
include
9696
)
9797

98+
# Suppressions required to build clean with GCC
99+
if(CMAKE_C_COMPILER_ID STREQUAL GNU)
100+
set_source_files_properties(FreeRTOS_Sockets.c PROPERTIES COMPILE_FLAGS -Wno-pedantic)
101+
endif()
102+
98103
target_link_libraries( freertos_plus_tcp
99104
PUBLIC
100105
freertos_config

source/include/FreeRTOS_IPv4.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444
/* Forward declarations. */
4545
struct xNETWORK_BUFFER;
46-
enum eFrameProcessingResult;
4746
struct xIP_PACKET;
4847

4948
#define ipSIZE_OF_IPv4_HEADER 20U
@@ -97,15 +96,6 @@ BaseType_t xIsIPv4Loopback( uint32_t ulAddress );
9796
*/
9897
BaseType_t xBadIPv4Loopback( const IPHeader_t * const pxIPHeader );
9998

100-
/* The function 'prvAllowIPPacket()' checks if a packets should be processed. */
101-
enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * const pxIPPacket,
102-
const struct xNETWORK_BUFFER * const pxNetworkBuffer,
103-
UBaseType_t uxHeaderLength );
104-
105-
/* Check if the IP-header is carrying options. */
106-
enum eFrameProcessingResult prvCheckIP4HeaderOptions( struct xNETWORK_BUFFER * const pxNetworkBuffer );
107-
108-
10999
/* *INDENT-OFF* */
110100
#ifdef __cplusplus
111101
} /* extern "C" */

source/include/FreeRTOS_IPv4_Private.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ struct xTCP_PACKET
125125
#include "pack_struct_end.h"
126126
typedef struct xTCP_PACKET TCPPacket_t;
127127

128+
129+
/* The function 'prvAllowIPPacket()' checks if a packets should be processed. */
130+
enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * const pxIPPacket,
131+
const struct xNETWORK_BUFFER * const pxNetworkBuffer,
132+
UBaseType_t uxHeaderLength );
133+
134+
/* Check if the IP-header is carrying options. */
135+
enum eFrameProcessingResult prvCheckIP4HeaderOptions( struct xNETWORK_BUFFER * const pxNetworkBuffer );
136+
128137
/* *INDENT-OFF* */
129138
#ifdef __cplusplus
130139
} /* extern "C" */

test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
#include "mock_FreeRTOS_IP.h"
4848
#include "mock_FreeRTOS_IP_Private.h"
49+
#include "mock_FreeRTOS_IPv4_Private.h"
4950
#include "mock_FreeRTOS_IP_Utils.h"
5051
#include "mock_FreeRTOS_IP_Timers.h"
5152
#include "mock_FreeRTOS_TCP_IP.h"

test/unit-test/FreeRTOS_IP/ut.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ list(APPEND mock_list
3333
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_TCP_IP.h"
3434
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h"
3535
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h"
36+
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv4_Private.h"
3637
"${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h"
3738
"${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkInterface.h"
3839
"${MODULE_ROOT_DIR}/test/unit-test/${project_name}/IP_list_macros.h"

test/unit-test/FreeRTOS_IPv4_DiffConfig/ut.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ list(APPEND mock_list
1717
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h"
1818
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h"
1919
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Utils.h"
20-
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv4_Private.h"
2120
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h"
2221
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h"
2322
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ICMP.h"

test/unit-test/FreeRTOS_IPv4_DiffConfig1/ut.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ list(APPEND mock_list
1717
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h"
1818
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Utils.h"
1919
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h"
20-
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv4_Private.h"
2120
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h"
2221
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h"
2322
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ICMP.h"

0 commit comments

Comments
 (0)