8223186: HotSpot compile warnings from GCC 9
authorysuenaga
Sat, 11 May 2019 01:17:18 +0900
changeset 54810 258170da6d3a
parent 54809 351da897f409
child 54811 9db7c0f561a6
8223186: HotSpot compile warnings from GCC 9 Reviewed-by: dholmes, aeubanks
src/hotspot/os/linux/osContainer_linux.cpp
src/hotspot/share/compiler/disassembler.cpp
src/hotspot/share/gc/shared/ptrQueue.cpp
src/hotspot/share/prims/jvmtiExport.hpp
--- a/src/hotspot/os/linux/osContainer_linux.cpp	Fri May 10 15:34:17 2019 +0100
+++ b/src/hotspot/os/linux/osContainer_linux.cpp	Sat May 11 01:17:18 2019 +0900
@@ -467,7 +467,7 @@
     log_trace(os, container)("Non-Hierarchical Memory Limit is: Unlimited");
     if (memory->is_hierarchical()) {
       const char* matchline = "hierarchical_memory_limit";
-      char* format = "%s " JULONG_FORMAT;
+      const char* format = "%s " JULONG_FORMAT;
       GET_CONTAINER_INFO_LINE(julong, memory, "/memory.stat", matchline,
                              "Hierarchical Memory Limit is: " JULONG_FORMAT, format, hier_memlimit)
       if (hier_memlimit >= _unlimited_memory) {
@@ -490,7 +490,7 @@
     log_trace(os, container)("Non-Hierarchical Memory and Swap Limit is: Unlimited");
     if (memory->is_hierarchical()) {
       const char* matchline = "hierarchical_memsw_limit";
-      char* format = "%s " JULONG_FORMAT;
+      const char* format = "%s " JULONG_FORMAT;
       GET_CONTAINER_INFO_LINE(julong, memory, "/memory.stat", matchline,
                              "Hierarchical Memory and Swap Limit is : " JULONG_FORMAT, format, hier_memlimit)
       if (hier_memlimit >= _unlimited_memory) {
--- a/src/hotspot/share/compiler/disassembler.cpp	Fri May 10 15:34:17 2019 +0100
+++ b/src/hotspot/share/compiler/disassembler.cpp	Sat May 11 01:17:18 2019 +0900
@@ -362,8 +362,12 @@
 }
 
 decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c,
-                       ptrdiff_t offset) {
-  memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields.
+                       ptrdiff_t offset) : _nm(NULL),
+                                           _start(NULL),
+                                           _end(NULL),
+                                           _option_buf(),
+                                           _print_raw('\0'),
+                                           _cur_insn(NULL) {
   _output = output ? output : tty;
   _code = code;
   if (code != NULL && code->is_nmethod())
--- a/src/hotspot/share/gc/shared/ptrQueue.cpp	Fri May 10 15:34:17 2019 +0100
+++ b/src/hotspot/share/gc/shared/ptrQueue.cpp	Sat May 11 01:17:18 2019 +0900
@@ -94,7 +94,7 @@
   _free_count(0),
   _transfer_lock(false)
 {
-  strncpy(_name, name, sizeof(_name));
+  strncpy(_name, name, sizeof(_name) - 1);
   _name[sizeof(_name) - 1] = '\0';
 }
 
--- a/src/hotspot/share/prims/jvmtiExport.hpp	Fri May 10 15:34:17 2019 +0100
+++ b/src/hotspot/share/prims/jvmtiExport.hpp	Sat May 11 01:17:18 2019 +0900
@@ -420,7 +420,7 @@
  public:
   JvmtiCodeBlobDesc(const char *name, address code_begin, address code_end) {
     assert(name != NULL, "all code blobs must be named");
-    strncpy(_name, name, sizeof(_name));
+    strncpy(_name, name, sizeof(_name) - 1);
     _name[sizeof(_name)-1] = '\0';
     _code_begin = code_begin;
     _code_end = code_end;