[OpenWrt-Devel] [PATCH fwtool] cmake: use extra compiler warnings only on gcc6+

Petr Štetiar ynezz at true.cz
Tue Nov 12 09:33:28 EST 2019


gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) and -Wextra produces
following:

 fwtool.c:288:9: error: missing initializer for field 'cur' of 'struct data_buf' [-Werror=missing-field-initializers]
  struct data_buf dbuf = {};
         ^
 fwtool.c:37:8: note: 'cur' declared here
  char *cur;
        ^

Ref: https://github.com/openwrt/openwrt/commit/4ba8f7b1ef1e4c0607185a41c06b51928c625d8b#commitcomment-35906526
Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-November/020039.html
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
 CMakeLists.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dfe6045fb4e8..0c2692a2a6ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,9 +3,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
 PROJECT(fwtool C)
 INCLUDE(GNUInstallDirs)
 
-ADD_DEFINITIONS(-Wall -Werror -Wextra -Wno-unused-parameter)
+ADD_DEFINITIONS(-Wall -Werror)
 ADD_EXECUTABLE(fwtool fwtool.c)
 
+IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
+	ADD_DEFINITIONS(-Wextra -Wno-unused-parameter)
+ENDIF()
+
 IF(UNIT_TESTING)
 	ENABLE_TESTING()
 	ADD_SUBDIRECTORY(tests)

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list