8030350: Enable additional compiler warnings for GCC
authormduigou
Wed, 12 Feb 2014 09:37:18 -0800
changeset 22784 f264891fc7a8
parent 22782 a3b1d68b373d
child 22785 4b36097c6eed
8030350: Enable additional compiler warnings for GCC Reviewed-by: dholmes, coleenp, erikj, tbell, ihse
hotspot/make/bsd/makefiles/gcc.make
hotspot/make/linux/makefiles/gcc.make
hotspot/make/solaris/makefiles/gcc.make
hotspot/src/os/bsd/vm/os_bsd.cpp
--- a/hotspot/make/bsd/makefiles/gcc.make	Tue Feb 11 21:32:19 2014 -0800
+++ b/hotspot/make/bsd/makefiles/gcc.make	Wed Feb 12 09:37:18 2014 -0800
@@ -260,7 +260,7 @@
   WARNINGS_ARE_ERRORS += -Wno-empty-body
 endif
 
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 -Wno-error=format-nonliteral
 
 ifeq ($(USE_CLANG),)
   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
@@ -289,7 +289,7 @@
 # The flags to use for an Optimized g++ build
 ifeq ($(OS_VENDOR), Darwin)
   # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
-  # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
+  # <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>
   OPT_CFLAGS_DEFAULT ?= SIZE
 else
   OPT_CFLAGS_DEFAULT ?= SPEED
--- a/hotspot/make/linux/makefiles/gcc.make	Tue Feb 11 21:32:19 2014 -0800
+++ b/hotspot/make/linux/makefiles/gcc.make	Wed Feb 12 09:37:18 2014 -0800
@@ -214,7 +214,7 @@
   WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
 endif
 
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wno-error=format-nonliteral
 
 ifeq ($(USE_CLANG),)
   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
--- a/hotspot/make/solaris/makefiles/gcc.make	Tue Feb 11 21:32:19 2014 -0800
+++ b/hotspot/make/solaris/makefiles/gcc.make	Wed Feb 12 09:37:18 2014 -0800
@@ -118,7 +118,7 @@
 # Compiler warnings are treated as errors 
 WARNINGS_ARE_ERRORS = -Werror 
 # Enable these warnings. See 'info gcc' about details on these options
-WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
+WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 -Wno-error=format-nonliteral
 CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
 # Special cases 
 CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))  
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Tue Feb 11 21:32:19 2014 -0800
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Wed Feb 12 09:37:18 2014 -0800
@@ -1834,7 +1834,7 @@
         jrelib_p = buf + len;
         snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT);
         if (0 != access(buf, F_OK)) {
-          snprintf(jrelib_p, buflen-len, "");
+          snprintf(jrelib_p, buflen-len, "%s", "");
         }
 
         // If the path exists within JAVA_HOME, add the JVM library name