Coverity has reported that cpu2 seems sometimes unused in
cpu_fixup_topology():
*** CID
1593776: Code maintainability issues (UNUSED_VALUE)
/src/cpu_topo.c: 690 in cpu_fixup_topology()
684 continue;
685
686 if (ha_cpu_topo[cpu].cl_gid != curr_id) {
687 if (curr_id >= 0 && cl_cpu <= 2)
688 small_cl++;
689 cl_cpu = 0;
>>> CID
1593776: Code maintainability issues (UNUSED_VALUE)
>>> Assigning value from "cpu" to "cpu2" here, but that stored value is overwritten before it can be used.
690 cpu2 = cpu;
691 curr_id = ha_cpu_topo[cpu].cl_gid;
692 }
693 cl_cpu++;
694 }
695
That's it. 'cpu2' automatic/stack variable is used only in for() loop scopes to
save cpus ID in which we are interested in. In the loop pointed by coverity
this variable is not used for further processing within the loop's scope.
Then it is always reinitialized to 0 in the another following loops.
This fixes GitHUb issue #2895.
curr_id = -1;
cl_cpu = small_cl = 0;
- for (cpu = cpu2 = 0; cpu <= cpu_topo_lastcpu; cpu++) {
+ for (cpu = 0; cpu <= cpu_topo_lastcpu; cpu++) {
if (ha_cpu_topo[cpu].cl_gid < 0)
continue;
if (curr_id >= 0 && cl_cpu <= 2)
small_cl++;
cl_cpu = 0;
- cpu2 = cpu;
curr_id = ha_cpu_topo[cpu].cl_gid;
}
cl_cpu++;