Closed
Description
Describe the bug
When compiling with the CMake options:
add_compile_options(
$<$<COMPILE_LANG_AND_ID:C,GNU>:-fdiagnostics-color=always>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcolor-diagnostics>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wall>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wextra>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wpedantic> # Note not used in GNU to allow C99 designated initializers.
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Werror>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Weverything>
# Allow clang and gnu pramgmas.
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-unknown-pragmas>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-typedef-redefinition>
# Documentation types
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcomment-block-commands=retval> # Doesn't recongize doxygen retval
$<$<COMPILE_LANG_AND_ID:C,Clang>:-fcomment-block-commands=copydetails> # Doesn't recongize doxygen copydetails
)
There are several isssues/warnings that arise when compling with Clang-14 when compiling V4.0.0-rc3
Target
- Development board: N/A - Linux Posix
- Instruction Set Architecture: arm64
- IDE and version: None - cmake build no IDE.
- Toolchain and version: clang-14.0.0-1ubuntu1
Host
- Host OS: Ubuntu
- Version: 22.04
To Reproduce
- Use project - any and configure with above
add_compile_options
- Build on ubuntu and could observe the following :
freertos_plus_tcp-src/source/FreeRTOS_BitConfig.c:135:15: error: parameter 'pxConfig:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_BitConfig.c:136:15: error: parameter 'pucData:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_BitConfig.c:137:15: error: parameter 'uxSize:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_BitConfig.c:203:59: error: implicit conversion loses integer precision: 'int' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
freertos_plus_tcp-src/source/FreeRTOS_DHCP.c:785:17: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_DHCP.c:1375:23: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Callback.c:154:62: error: implicit conversion loses integer precision: 'TickType_t' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Callback.c:276:10: error: no previous prototype for function 'vDNSCallbackInitialise' [-Werror,-Wmissing-prototypes]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Callback.c:276:32: error: this old-style function definition is not preceded by a prototype [-Werror,-Wstrict-prototypes]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Parser.c:474:60: error: implicit conversion loses integer precision: 'uint16_t' (aka 'unsigned short') to 'uint8_t' (aka 'unsigned char') [-Werror,-Wimplicit-int-conversion]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Parser.c:563:98: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Parser.c:575:122: error: implicit conversion loses integer precision: 'unsigned long' to 'int16_t' (aka 'short') [-Werror,-Wimplicit-int-conversion]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Parser.c:582:143: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Parser.c:1220:80: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
freertos_plus_tcp-src/source/FreeRTOS_DNS_Parser.c:1224:122: error: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Werror,-Wextra-semi-stmt]
freertos_plus_tcp-src/source/FreeRTOS_IP.c:236:1: error: function 'prvIPTask' could be declared with attribute 'noreturn' [-Werror,-Wmissing-noreturn]
freertos_plus_tcp-src/source/FreeRTOS_IP.c:478:9: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_IP.c:893:23: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_IP.c:1227:48: error: cast from 'const void *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_IP.c:1660:9: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_IP.c:1888:25: error: variable 'uxHeaderLength' may be uninitialized when used here [-Werror,-Wconditional-uninitialized]
freertos_plus_tcp-src/source/FreeRTOS_IP_Utils.c:1030:47: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_IP_Utils.c:67:13: error: macro is not used [-Werror,-Wunused-macros]
freertos_plus_tcp-src/source/FreeRTOS_IP_Utils.c:75:13: error: macro is not used [-Werror,-Wunused-macros]
freertos_plus_tcp-src/source/FreeRTOS_IPv6.c:640:16: error: variable 'xExtHeaderCount' set but not used [-Werror,-Wunused-but-set-variable]
freertos_plus_tcp-src/source/FreeRTOS_IPv4.c:420:86: error: unused parameter 'pxNetworkBuffer' [-Werror,-Wunused-parameter]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:933:33: error: enumeration value 'xPreferenceNone' not explicitly handled in switch [-Werror,-Wswitch-enum]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1011:42: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1031:49: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1002:25: error: enumeration value 'xPreferenceNone' not explicitly handled in switch [-Werror,-Wswitch-enum]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:862:20: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1188:20: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1561:13: error: cast from 'const struct xDNSTail *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1561:13: error: cast from 'const struct xDNSTail *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1562:13: error: cast from 'const struct xDNSTail *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_DNS.c:1562:13: error: cast from 'const struct xDNSTail *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_IPv4_Utils.c:130:16: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_IPv6_Sockets.c:229:12: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
freertos_plus_tcp-src/source/FreeRTOS_IPv6_Utils.c:101:16: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_ND.c:891:28: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_ND.c:1220:39: error: use of GNU statement expression extension [-Werror,-Wgnu-statement-expression]
freertos_plus_tcp-src/source/FreeRTOS_ND.c:1220:39: error: '(' and '{' tokens introducing statement expression are separated by whitespace [-Werror,-Wcompound-token-split-by-space]
freertos_plus_tcp-src/source/FreeRTOS_ND.c:1220:39: error: '}' and ')' tokens terminating statement expression are separated by whitespace [-Werror,-Wcompound-token-split-by-space]
freertos_plus_tcp-src/source/FreeRTOS_ND.c:1244:20: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_ND.c:69:13: error: macro is not used [-Werror,-Wunused-macros]
freertos_plus_tcp-src/source/FreeRTOS_RA.c:521:17: error: enumeration values 'eRAStateWait' and 'eRAStateIPWait' not explicitly handled in switch [-Werror,-Wswitch-enum]
freertos_plus_tcp-src/source/FreeRTOS_RA.c:632:24: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:867:61: error: cast from 'const unsigned char *' to 'void *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:871:63: error: cast from 'const unsigned char *' to 'void *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:1459:35: error: use of GNU statement expression extension [-Werror,-Wgnu-statement-expression]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:1459:35: error: '(' and '{' tokens introducing statement expression are separated by whitespace [-Werror,-Wcompound-token-split-by-space]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:1459:35: error: '}' and ')' tokens terminating statement expression are separated by whitespace [-Werror,-Wcompound-token-split-by-space]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:1462:67: error: implicit conversion loses integer precision: 'int' to 'uint16_t' (aka 'unsigned short') [-Werror,-Wimplicit-int-conversion]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:1507:50: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
freertos_plus_tcp-src/source/FreeRTOS_Routing.c:1516:50: error: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
freertos_plus_tcp-src/source/FreeRTOS_TCP_IP_IPV6.c:112:31: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_TCP_IP.c:187:123: error: implicit conversion loses integer precision: 'unsigned long' to 'uint32_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
freertos_plus_tcp-src/source/FreeRTOS_TCP_IP.c:471:21: error: 10 enumeration values not explicitly handled in switch: 'eCLOSED', 'eTCP_LISTEN', 'eCONNECT_SYN'... [-Werror,-Wswitch-enum]
freertos_plus_tcp-src/source/FreeRTOS_TCP_IP.c:655:20: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Transmission_IPV4.c:237:32: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Transmission_IPV4.c:351:9: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_TCP_State_Handling_IPV6.c:177:33: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_TCP_State_Handling.c:117:13: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_TCP_State_Handling.c:171:17: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_TCP_State_Handling.c:885:17: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:1451:76: error: cast from 'const struct xSOCKET *' to 'struct xSOCKET *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:2202:48: error: format specifies type 'void *' but the argument has type 'uint8_t *' (aka 'unsigned char *') [-Werror,-Wformat-pedantic]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:2204:48: error: format specifies type 'void *' but the argument has type 'uint8_t *' (aka 'unsigned char *') [-Werror,-Wformat-pedantic]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:2234:44: error: format specifies type 'void *' but the argument has type 'uint8_t *' (aka 'unsigned char *') [-Werror,-Wformat-pedantic]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:2873:80: error: cast from 'const void *' to 'struct QueueDefinition **' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:2896:83: error: cast from 'const void *' to 'void (*)(struct xSOCKET *)' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:3342:38: error: implicit conversion changes signedness: 'char' to 'unsigned int' [-Werror,-Wsign-conversion]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:3633:13: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:3774:38: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:5109:43: error: cast from 'const unsigned char *' to 'unsigned char *' drops const qualifier [-Werror,-Wcast-qual]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:5768:11: error: empty paragraph passed to '@return' command [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:5768:5: error: '@return' command used in a comment that is attached to a function returning void [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_Sockets.c:5812:48: error: format specifies type 'void *' but the argument has type 'const uint8_t *' (aka 'const unsigned char *') [-Werror,-Wformat-pedantic]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Utils.c:64:5: error: '@param' command used in a comment that is not attached to a function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Utils.c:66:5: error: '@return' command used in a comment that is not attached to a function or method declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Utils_IPV6.c:97:25: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Transmission_IPV6.c:233:32: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_TCP_Transmission_IPV6.c:359:9: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IP.c:93:15: error: parameter 'pxNetworkBuffer:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IP.c:131:15: error: parameter 'pxNetworkBuffer:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IP.c:132:15: error: parameter 'usPort:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IP.c:133:16: error: parameter 'pxIsWaitingForARPResolution:' not found in the function declaration [-Werror,-Wdocumentation]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IP.c:153:25: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IPv4.c:68:9: error: macro is not used [-Werror,-Wunused-macros]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IPv4.c:360:31: error: mixing declarations and code is a C99 extension [-Werror,-Wdeclaration-after-statement]
freertos_plus_tcp-src/source/FreeRTOS_UDP_IPv6.c:70:9: error: macro is not used [-Werror,-Wunused-macros]
freertos_plus_tcp-src/source/portable/NetworkInterface/linux/NetworkInterface.c:869:44: error: cast from 'const unsigned char *' to 'struct xETH_HEADER *' drops const qualifier [-Werror,-Wcast-qual]
Expected behavior
Should be warning clean or explicitly state that you are allowing these to be in the code so the consumer knows some level of expectations of ignored warnings.
cast-qual
- should fix these.compound-token-split-by-space
- should fix theseconditional-uninitialized
- BUG may not be initialized in all casescovered-switch-default
- either allow or fixdeclaration-after-statement
- BUG - this means it is not C89 compliant code, can only be used with C99 or higher compilers.documentation
- BUG issues with documentation for doxygen generationextra-semi-stmt
- either allow or fixformat-pedantic
- either allow or fix - typically identify issues in string formattinggnu-statement-expression
- BUG - this means must have a compiler that supports gnu statements of this natureimplicit-int-conversion
- either allow or fixmissing-noreturn
- either allow or fixmissing-prototypes
- add the prototype definitions - or add the missing headers that define themshorten-64-to-32
- issue for 64-bit machines - use proper size_t or uintptr_t types defined in std headers.sign-conversion
- should fixstrict-prototypes
- should fixswitch-enum
-unused-but-set-variable
- either remove or allowunused-macros
- remove or if they are only used due to your config - wrap with the config that uses those macros as well.unused-parameter
- remove or if they are only used due to your config - wrap with the config that uses those parameters as well.
If you are fine with these then please add them to your definition of the CMakeLists.txt for freertos_plus_tcp targets via:
target_compile_options(freertos_plus_tcp
PRIVATE
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-compound-token-split-by-space>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-conditional-uninitialized>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-covered-switch-default>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-declaration-after-statement>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-documentation>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-extra-semi-stmt>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-format-pedantic>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-gnu-statement-expression>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-implicit-int-conversion>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-noreturn>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-missing-prototypes>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-shorten-64-to-32>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-sign-conversion>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-strict-prototypes>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-switch-enum>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-but-set-variable>
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-unused-macros>
$<$<COMPILE_LANG_AND_ID:C,Clang,GNU>:-Wno-unused-parameter>
)
target_compile_options(freertos_plus_tcp_network_if
PRIVATE
$<$<COMPILE_LANG_AND_ID:C,Clang>:-Wno-cast-qual>
)
Screenshots
N/A
Wireshark logs
N/A
Additional context
N/A