mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-04-14 10:12:43 +02:00
MINOR: cpu-topo: fix unused stack var 'cpu2' reported by coverity
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.
This commit is contained in:
parent
de67f25a7e
commit
557f62593f
@ -676,7 +676,7 @@ void cpu_fixup_topology(void)
|
||||
|
||||
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;
|
||||
|
||||
@ -687,7 +687,6 @@ void cpu_fixup_topology(void)
|
||||
if (curr_id >= 0 && cl_cpu <= 2)
|
||||
small_cl++;
|
||||
cl_cpu = 0;
|
||||
cpu2 = cpu;
|
||||
curr_id = ha_cpu_topo[cpu].cl_gid;
|
||||
}
|
||||
cl_cpu++;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user