8223810: HotSpot compile warnings from VS2017
authordholmes
Tue, 14 May 2019 20:29:40 -0400
changeset 54851 f67269c129f9
parent 54850 f8d45530b75e
child 54852 ddb27517396c
child 57357 f3beca8f19fc
8223810: HotSpot compile warnings from VS2017 Reviewed-by: dholmes, stuefe Contributed-by: Andrew Luo <andrewluotechnologies@outlook.com>
src/hotspot/os/windows/os_windows.cpp
src/hotspot/share/services/attachListener.hpp
test/hotspot/gtest/gtestMain.cpp
--- a/src/hotspot/os/windows/os_windows.cpp	Tue May 14 15:09:31 2019 -0700
+++ b/src/hotspot/os/windows/os_windows.cpp	Tue May 14 20:29:40 2019 -0400
@@ -201,7 +201,7 @@
     char *home_path;
     char *dll_path;
     char *pslash;
-    char *bin = "\\bin";
+    const char *bin = "\\bin";
     char home_dir[MAX_PATH + 1];
     char *alt_home_dir = ::getenv("_ALT_JAVA_HOME_DIR");
 
@@ -2185,7 +2185,7 @@
 
 #define def_excpt(val) { #val, (val) }
 
-static const struct { char* name; uint number; } exceptlabels[] = {
+static const struct { const char* name; uint number; } exceptlabels[] = {
     def_excpt(EXCEPTION_ACCESS_VIOLATION),
     def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT),
     def_excpt(EXCEPTION_BREAKPOINT),
@@ -5335,7 +5335,7 @@
   DWORD exit_code;
 
   char * cmd_string;
-  char * cmd_prefix = "cmd /C ";
+  const char * cmd_prefix = "cmd /C ";
   size_t len = strlen(cmd) + strlen(cmd_prefix) + 1;
   cmd_string = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtInternal);
   if (cmd_string == NULL) {
@@ -5674,8 +5674,8 @@
 */
 int os::get_signal_number(const char* name) {
   static const struct {
-    char* name;
-    int   number;
+    const char* name;
+    int         number;
   } siglabels [] =
     // derived from version 6.0 VC98/include/signal.h
   {"ABRT",      SIGABRT,        // abnormal termination triggered by abort cl
--- a/src/hotspot/share/services/attachListener.hpp	Tue May 14 15:09:31 2019 -0700
+++ b/src/hotspot/share/services/attachListener.hpp	Tue May 14 20:29:40 2019 -0400
@@ -121,7 +121,7 @@
   const char* name() const                      { return _name; }
 
   // set the operation name
-  void set_name(char* name) {
+  void set_name(const char* name) {
     assert(strlen(name) <= name_length_max, "exceeds maximum name length");
     size_t len = MIN2(strlen(name), (size_t)name_length_max);
     memcpy(_name, name, len);
@@ -148,7 +148,7 @@
   }
 
   // create an operation of a given name
-  AttachOperation(char* name) {
+  AttachOperation(const char* name) {
     set_name(name);
     for (int i=0; i<arg_count_max; i++) {
       set_arg(i, NULL);
--- a/test/hotspot/gtest/gtestMain.cpp	Tue May 14 15:09:31 2019 -0700
+++ b/test/hotspot/gtest/gtestMain.cpp	Tue May 14 20:29:40 2019 -0400
@@ -231,7 +231,7 @@
 #endif // __APPLE__
 
 #else  // _WIN32
-  char* java_home_var = "_ALT_JAVA_HOME_DIR";
+  const char* java_home_var = "_ALT_JAVA_HOME_DIR";
   size_t len = strlen(java_home) + strlen(java_home_var) + 2;
   char * envString = new char[len];
   sprintf_s(envString, len, "%s=%s", java_home_var, java_home);