8259563: The CPU model name is printed multiple times when using -Xlog:os+cpu

Reviewed-by: dholmes
This commit is contained in:
Wang Xue 2021-01-14 12:56:56 +00:00 committed by David Holmes
parent b040a3d7a9
commit b8ef2bad52

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, 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
@ -2464,10 +2464,10 @@ static bool print_model_name_and_flags(outputStream* st, char* buf, size_t bufle
// Other platforms have less repetitive cpuinfo files
FILE *fp = fopen("/proc/cpuinfo", "r");
if (fp) {
bool model_name_printed = false;
while (!feof(fp)) {
if (fgets(buf, buflen, fp)) {
// Assume model name comes before flags
bool model_name_printed = false;
if (strstr(buf, "model name") != NULL) {
if (!model_name_printed) {
st->print_raw("CPU Model and flags from /proc/cpuinfo:\n");