< prev index next >

src/hotspot/cpu/x86/vm_version_ext_x86.cpp

Print this page
rev 50985 : 8206977: Minor improvements of runtime code.
Reviewed-by: coleenp, lfoltan

@@ -468,23 +468,22 @@
 
   return OS_OK;
 }
 
 size_t VM_Version_Ext::cpu_write_support_string(char* const buf, size_t buf_len) {
-  assert(buf != NULL, "buffer is NULL!");
-  assert(buf_len > 0, "buffer len not enough!");
+  guarantee(buf != NULL, "buffer is NULL!");
+  guarantee(buf_len > 0, "buffer len not enough!");
 
   unsigned int flag = 0;
   unsigned int fi = 0;
   size_t       written = 0;
   const char*  prefix = "";
 
 #define WRITE_TO_BUF(string)                                                          \
   {                                                                                   \
     int res = jio_snprintf(&buf[written], buf_len - written, "%s%s", prefix, string); \
-    if (res < 0 || (size_t) res >= buf_len - 1) {                                     \
-      buf[buf_len-1] = '\0';                                                          \
+    if (res < 0) {                                                                    \
       return buf_len - 1;                                                             \
     }                                                                                 \
     written += res;                                                                   \
     if (prefix[0] == '\0') {                                                          \
       prefix = ", ";                                                                  \

@@ -590,11 +589,11 @@
     _cpuid_info.ext_cpuid1_ebx,
     _cpuid_info.ext_cpuid1_ecx,
     _cpuid_info.ext_cpuid1_edx);
 
   if (outputLen < 0 || (size_t) outputLen >= buf_len - 1) {
-    buf[buf_len-1] = '\0';
+    if (buf_len > 0) { buf[buf_len-1] = '\0'; }
     return OS_ERR;
   }
 
   cpu_write_support_string(&buf[outputLen], buf_len - outputLen);
 
< prev index next >