8130036: Fix problems with imprecise C++ coding.
authorgoetz
Mon, 29 Jun 2015 10:16:48 +0200
changeset 31615 e48d94b97b6c
parent 31614 f60b185e0bdf
child 31617 f57169882c49
8130036: Fix problems with imprecise C++ coding. Reviewed-by: dholmes, kbarrett
hotspot/src/share/vm/compiler/compilerOracle.cpp
hotspot/src/share/vm/runtime/reflection.cpp
hotspot/src/share/vm/utilities/vmError.cpp
--- a/hotspot/src/share/vm/compiler/compilerOracle.cpp	Mon Jun 29 13:48:55 2015 -0700
+++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp	Mon Jun 29 10:16:48 2015 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -578,7 +578,7 @@
                       int* bytes_read, const char*& error_msg) {
   *bytes_read = 0;
   error_msg = NULL;
-  if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255"  RANGE0 "%n", class_name, method_name, bytes_read)) {
+  if (2 == sscanf(line, "%*[ \t]%255" RANGESLASH "%*[ ]" "%255" RANGE0 "%n", class_name, method_name, bytes_read)) {
     *c_mode = check_mode(class_name, error_msg);
     *m_mode = check_mode(method_name, error_msg);
     return *c_mode != MethodMatcher::Unknown && *m_mode != MethodMatcher::Unknown;
@@ -586,8 +586,6 @@
   return false;
 }
 
-
-
 // Scan next flag and value in line, return MethodMatcher object on success, NULL on failure.
 // On failure, error_msg contains description for the first error.
 // For future extensions: set error_msg on first error.
@@ -665,7 +663,7 @@
           jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
         }
       } else {
-        jio_snprintf(errorbuf, sizeof(errorbuf), "  Value cannot be read for flag %s of type %s", flag, type);
+        jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
       }
     } else if (strcmp(type, "double") == 0) {
       char buffer[2][256];
@@ -680,10 +678,10 @@
         jio_snprintf(errorbuf, buf_size, "  Value cannot be read for flag %s of type %s", flag, type);
       }
     } else {
-      jio_snprintf(errorbuf, sizeof(errorbuf), "  Type %s not supported ", type);
+      jio_snprintf(errorbuf, buf_size, "  Type %s not supported ", type);
     }
   } else {
-    jio_snprintf(errorbuf, sizeof(errorbuf), "  Flag name for type %s should be alphanumeric ", type);
+    jio_snprintf(errorbuf, buf_size, "  Flag name for type %s should be alphanumeric ", type);
   }
   return NULL;
 }
--- a/hotspot/src/share/vm/runtime/reflection.cpp	Mon Jun 29 13:48:55 2015 -0700
+++ b/hotspot/src/share/vm/runtime/reflection.cpp	Mon Jun 29 10:16:48 2015 +0200
@@ -1002,8 +1002,9 @@
                 vmSymbols::throwable_void_signature(),
                 &args);
   } else {
-    if (rtype == T_BOOLEAN || rtype == T_BYTE || rtype == T_CHAR || rtype == T_SHORT)
+    if (rtype == T_BOOLEAN || rtype == T_BYTE || rtype == T_CHAR || rtype == T_SHORT) {
       narrow((jvalue*) result.get_value_addr(), rtype, CHECK_NULL);
+    }
     return box((jvalue*) result.get_value_addr(), rtype, THREAD);
   }
 }
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Mon Jun 29 13:48:55 2015 -0700
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Mon Jun 29 10:16:48 2015 +0200
@@ -411,9 +411,10 @@
            }
            st->cr();
          } else {
-           if (_message != NULL)
+           if (_message != NULL) {
              st->print("# ");
              st->print_cr("%s", _message);
+           }
          }
          // In error file give some solutions
          if (_verbose) {