--- a/src/hotspot/os/linux/stathist_linux.cpp Wed Mar 06 17:31:25 2019 +0100
+++ b/src/hotspot/os/linux/stathist_linux.cpp Wed Mar 06 15:43:13 2019 +0100
@@ -70,11 +70,7 @@
const char* text() const { return _buf; }
const char* get_prefixed_line(const char* prefix) const {
- const char* p = ::strstr(_buf, prefix);
- if (p != NULL) {
- return p;
- }
- return NULL;
+ return ::strstr(_buf, prefix);
}
value_t parsed_prefixed_value(const char* prefix, size_t scale = 1) const {
@@ -83,8 +79,9 @@
if (s != NULL) {
errno = 0;
const char* p = s + ::strlen(prefix);
- value = (value_t)::strtoll(p, NULL, 10);
- if (value == 0 && errno != 0) {
+ char* endptr = NULL;
+ value = (value_t)::strtoll(p, &endptr, 10);
+ if (p == endptr || errno != 0) {
value = INVALID_VALUE;
} else {
value *= scale;
@@ -162,13 +159,13 @@
const uint64_t delta_ms = value_ms - last_value_ms;
// Calculate the number of wallclock milliseconds for the delta interval...
- const int age_ms = last_value_age * 1000;
+ const uint64_t age_ms = last_value_age * 1000;
// times number of available cores.
- const int total_cpu_time_ms = age_ms * _num_cores;
+ const uint64_t total_cpu_time_ms = age_ms * _num_cores;
// Put the spent cpu time in reference to the total available cpu time.
- const float percentage = (100.0f * delta_ms) / total_cpu_time_ms;
+ const double percentage = (100.0f * delta_ms) / total_cpu_time_ms;
char buf[32];
l = jio_snprintf(buf, sizeof(buf), "%.0f", percentage);
--- a/src/hotspot/share/services/stathist.cpp Wed Mar 06 17:31:25 2019 +0100
+++ b/src/hotspot/share/services/stathist.cpp Wed Mar 06 15:43:13 2019 +0100
@@ -135,19 +135,6 @@
}
}
-// A little RAII class to temporarily change locale to "C"
-class CLocaleMark {
- const char* _orig;
-public:
- CLocaleMark() {
- _orig = ::setlocale(LC_NUMERIC, NULL);
- ::setlocale(LC_NUMERIC, "C");
- }
- ~CLocaleMark() {
- ::setlocale(LC_NUMERIC, _orig);
- }
-};
-
////// class ColumnList methods ////
ColumnList* ColumnList::_the_list = NULL;
@@ -689,9 +676,6 @@
void print_table(outputStream* st, const print_info_t* pi, const record_t* values_now = NULL) const {
- // print numbers with C locale to make parsing easier.
- CLocaleMark clm;
-
if (is_empty() && values_now == NULL) {
st->print_cr("(no records)");
return;
@@ -1175,8 +1159,6 @@
st->cr();
}
- CLocaleMark locale_mark; // Print all numbers with locale "C"
-
record_t* values_now = NULL;
if (!pi->avoid_sampling) {
// Sample the current values (not when reporting errors, since we do not want to risk secondary errors).