diff options
author | Dave Jones <davej@redhat.com> | 2011-02-22 15:04:02 -0500 |
---|---|---|
committer | Dave Jones <davej@redhat.com> | 2011-02-22 15:04:02 -0500 |
commit | cbdb9fe128ae7ff684f7e0d785bae2a85ebfcfaf (patch) | |
tree | e4b9cab3016da884f6fb3310d843bce68c0bd021 | |
parent | 8f480c8f5d0fcaadfebe079a7a288b4712034331 (diff) |
split out to separate function
-rw-r--r-- | x86info.c | 67 |
1 files changed, 37 insertions, 30 deletions
@@ -380,12 +380,47 @@ static void display_detailed_info(struct cpudata *cpu) show_benchmarks(cpu); } +/* + * check to see if all CPUs are the same. + * returns 1 if all cpus are the same, 0 if something is different + */ +static int check_cpu_similarity() +{ + struct cpudata *cpu; + unsigned int i; + + /* force to display all cpus if the user requested it. */ + if (all_cpus == 1) + return 0; + + cpu = firstcpu; + if (nrCPUs > 1) { + for (i = 0; i < nrCPUs; i++) { + cpu = cpu->next; + if (!cpu) + return 1; + + if (cpu->efamily != firstcpu->efamily) + return 0; + if (cpu->emodel != firstcpu->emodel) + return 0; + if (cpu->family != firstcpu->family) + return 0; + if (model(cpu) != model(firstcpu)) + return 0; + if (cpu->stepping != firstcpu->stepping) + return 0; + } + } + return 1; +} + int main (int argc, char **argv) { struct cpudata *cpu=NULL, *head=NULL, *tmp; unsigned int i; - unsigned int display_one_cpu; + unsigned int display_one_cpu = 1; if (getuid() != 0) user_is_root=0; @@ -446,35 +481,7 @@ int main (int argc, char **argv) identify(cpu); } - /* check to see if all CPUs are the same. */ - display_one_cpu = 1; - - cpu = firstcpu; - if (nrCPUs > 1) { - for (i = 0; i < nrCPUs; i++) { - cpu = cpu->next; - if (!cpu) - break; - if (cpu->efamily != firstcpu->efamily) - display_one_cpu = 0; - if (cpu->emodel != firstcpu->emodel) - display_one_cpu = 0; - if (cpu->family != firstcpu->family) - display_one_cpu = 0; - if (model(cpu) != model(firstcpu)) - display_one_cpu = 0; - if (cpu->stepping != firstcpu->stepping) - display_one_cpu = 0; - - if (display_one_cpu == 0) - break; - } - } - - /* force to display all cpus if the user requested it. */ - if (all_cpus == 1) - display_one_cpu = 0; - + display_one_cpu = check_cpu_similarity(); if (show_mptable && user_is_root) display_mptable(); |