mirror of
https://github.com/anrieff/libcpuid
synced 2024-11-20 23:01:51 +00:00
Fix a regression in cpuid_tool when ident_required=0 for arg
In 2b8023f733
, I had to update the behavior of cpuid_tool to loop over all data.cpu_types items.
I did not realize since this change, it was not entering the loop for args with ident_required=0, because data.num_cpu_types was always 0, so print_info() was never called for such args.
In other words, args like --rdmsr or --cpuid did nothing due to this regression. This commit fix this regression.
This commit is contained in:
parent
d31e2fd73b
commit
b7940c7029
1 changed files with 25 additions and 13 deletions
|
@ -374,6 +374,13 @@ static void print_info(output_data_switch query, struct cpu_id_t* data)
|
|||
{
|
||||
int i, value;
|
||||
struct msr_driver_t* handle;
|
||||
|
||||
/* Check if function is properly called */
|
||||
if ((data == NULL) && check_need_raw_data()) {
|
||||
fprintf(stderr, "print_info: raw data is required but not provided.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (query) {
|
||||
case NEED_CPUID_PRESENT:
|
||||
fprintf(fout, "%d\n", cpuid_present());
|
||||
|
@ -859,8 +866,9 @@ int main(int argc, char** argv)
|
|||
}
|
||||
/* OK, process all queries. */
|
||||
if (((!need_report || !only_clock_queries) && num_requests > 0) || need_identify) {
|
||||
if (check_need_raw_data()) {
|
||||
/* Identify the CPU. Make it do cpuid_get_all_raw_data() itself */
|
||||
if (check_need_raw_data() && cpu_identify_all(&raw_array, &data) < 0) {
|
||||
if (cpu_identify_all(&raw_array, &data) < 0) {
|
||||
if (!need_quiet)
|
||||
fprintf(stderr,
|
||||
"Error identifying the CPU: %s\n",
|
||||
|
@ -875,6 +883,10 @@ int main(int argc, char** argv)
|
|||
print_info(requests[i], &data.cpu_types[cpu_type_index]);
|
||||
}
|
||||
}
|
||||
else
|
||||
for (i = 0; i < num_requests; i++)
|
||||
print_info(requests[i], NULL);
|
||||
}
|
||||
if (need_cpulist) {
|
||||
print_cpulist();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue