Bugfix/fix redundant compiler flags (#658)

* Improved GCC compiler flags in ARM, OS, and test builds. Removed redundant flags, and made them consistent across various builds.

* Fixed redundant redeclaration of various functions detected by change in compiler flags.

* Fixed string truncation warning in bip-init detected by change in compiler flags.

* Fixed some set-but-not-used variables by creating dummy functions instead of using macros.
This commit is contained in:
Steve Karg
2024-05-30 10:59:54 -05:00
committed by GitHub
parent 0cbf7414a4
commit 52f3f08cb1
20 changed files with 130 additions and 144 deletions
+13 -2
View File
@@ -191,9 +191,20 @@ target_compile_definitions(${EXECUTABLE} PRIVATE
-DBACAPP_MINIMAL
)
# inhibit pedantic warnings
target_compile_options(${EXECUTABLE} PRIVATE
-Wall
-Wall -Wextra -pedantic
-Wfloat-equal -Wconversion -Wredundant-decls
-Wswitch-default
# don't warn about conversion, sign, compares, long long and attributes
# since they are common in embedded
-Wno-sign-conversion
-Wno-conversion
-Wno-sign-compare
-Wno-long-long
-Wno-attributes
# don't warn about implicit fallthrough since it is common in network protocols
-Wno-implicit-fallthrough
# the older Atmel SDK does not meet coding guidelines
-Wno-comment
-Wno-missing-braces
-Wno-unused-variable
+16 -2
View File
@@ -38,8 +38,22 @@ CFLAGS = -fno-common $(INCLUDES) $(BACNET_FLAGS) -g
CFLAGS += -mno-thumb-interwork
# dead code removal
CFLAGS += -fdata-sections -ffunction-sections
# warning control
CFLAGS += -Wall
# enable all relevant warnings that find bugs
WARNING_ALL := -Wall -Wextra -Wfloat-equal -Wconversion
WARNING_ALL += -Wredundant-decls -Wswitch-default -pedantic
# don't warn about conversion, sign, compares, long long and attributes
# since they are common in embedded
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
WARNING_ALL += -Wno-long-long -Wno-attributes
# don't warn about implicit fallthrough since it's common in network protocols
WARNING_ALL += -Wno-implicit-fallthrough
# the older Atmel SDK does not meet coding guidelines
WARNING_ALL += -Wno-comment -Wno-missing-braces
WARNING_ALL += -Wno-unused-variable -Wno-char-subscripts
#WARNING_ALL += -Werror
CFLAGS += $(WARNING_ALL)
CFLAGS += -Wno-char-subscripts
LIBRARY = lib$(TARGET).a
+1 -1
View File
@@ -899,7 +899,7 @@ bool bip_init(char *ifname)
int sock_fd = -1;
if (ifname) {
strncpy(BIP_Interface_Name, ifname, sizeof(BIP_Interface_Name));
snprintf(BIP_Interface_Name, sizeof(BIP_Interface_Name), "%s", ifname);
bip_set_interface(ifname);
} else {
bip_set_interface(ifname_default());
+16 -16
View File
@@ -165,25 +165,25 @@ CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin
# place uninitialized global variables in the data section of the object file.
CFLAGS += -fno-common
WARNING_ALL := -Wall
# enable all relevant warnings that find bugs
#WARNING_ALL += -pedantic -Wextra -Wfloat-equal -Wconversion -Wparentheses
#WARNING_ALL += -Wunused-parameter -Wunused-variable -Wreturn-type
#WARNING_ALL += -Wunused-function -Wreturn-type -Wunused-value
#WARNING_ALL += -Wswitch-default -Wuninitialized -Winit-self
#WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
#WARNING_ALL += -Wno-long-long
#WARNING_ALL += -Wredundant-decls
WARNING_ALL := -Wall -Wextra -Wfloat-equal -Wconversion
WARNING_ALL += -Wredundant-decls -Wswitch-default -pedantic
# don't warn about conversion, sign, compares, long long and attributes
# since they are common in embedded
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
WARNING_ALL += -Wno-long-long -Wno-attributes
# don't warn about implicit fallthrough since it's common in network protocols
WARNING_ALL += -Wno-implicit-fallthrough
# don't warn about missing braces since GCC is over-achiever for this
WARNING_ALL += -Wno-missing-braces
# don't warn about missing prototypes since STM32 library doesn't have some
WARNING_ALL += -Wno-missing-prototypes
# don't warn about array subscript being char
WARNING_ALL += -Wno-char-subscripts
# FIXME later
WARNING_ALL += -Wno-unused-parameter
#WARNING_ALL += -Werror
CFLAGS += $(WARNING_ALL)
# don't warn about missing braces since GCC is over-achiever for this
CFLAGS += -Wno-missing-braces
# don't warn about missing prototypes since STM32 library doesn't have some
CFLAGS += -Wno-missing-prototypes
# don't warn about array subscript being char
CFLAGS += -Wno-char-subscripts
# FIXME later
CFLAGS += -Wno-unused-parameter
# -Wa,<options> Pass comma-separated <options> on to the assembler
AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst)
+15 -1
View File
@@ -226,10 +226,24 @@ target_compile_definitions(${EXECUTABLE} PRIVATE
# inhibit pedantic warnings
target_compile_options(${EXECUTABLE} PRIVATE
-Wall
-Wall -Wextra -pedantic
-Wfloat-equal -Wconversion -Wredundant-decls
-Wswitch-default
# don't warn about conversion, sign, compares, long long and attributes
# since they are common in embedded
-Wno-sign-conversion
-Wno-conversion
-Wno-sign-compare
-Wno-long-long
-Wno-attributes
# don't warn about implicit fallthrough since it is common in network protocols
-Wno-implicit-fallthrough
# the SDK does not meet coding guidelines
-Wno-comment
-Wno-missing-braces
-Wno-unused-variable
-Wno-unused-parameter
-Wno-char-subscripts
)
target_include_directories(${EXECUTABLE} PRIVATE
+16 -5
View File
@@ -177,14 +177,25 @@ CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin
# place uninitialized global variables in the data section of the object file.
CFLAGS += -fno-common
# enable all relevant warnings
CFLAGS += -Wall
# enable all relevant warnings that find bugs
WARNING_ALL := -Wall -Wextra -Wfloat-equal -Wconversion
WARNING_ALL += -Wredundant-decls -Wswitch-default -pedantic
# don't warn about conversion, sign, compares, long long and attributes
# since they are common in embedded
WARNING_ALL += -Wno-sign-conversion -Wno-conversion -Wno-sign-compare
WARNING_ALL += -Wno-long-long -Wno-attributes
# don't warn about implicit fallthrough since it's common in network protocols
WARNING_ALL += -Wno-implicit-fallthrough
# don't warn about missing braces since GCC is over-achiever for this
CFLAGS += -Wno-missing-braces
WARNING_ALL += -Wno-missing-braces
# don't warn about missing prototypes since STM32 library doesn't have some
CFLAGS += -Wno-missing-prototypes
WARNING_ALL += -Wno-missing-prototypes
# don't warn about array subscript being char
CFLAGS += -Wno-char-subscripts
WARNING_ALL += -Wno-char-subscripts
# FIXME later
WARNING_ALL += -Wno-unused-parameter
#WARNING_ALL += -Werror
CFLAGS += $(WARNING_ALL)
# -Wa,<options> Pass comma-separated <options> on to the assembler
AFLAGS = -Wa,-ahls,-mapcs-32,-adhlns=$(<:.s=.lst)