]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: cpu-topo: fix unused stack var 'cpu2' reported by coverity
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Mon, 17 Mar 2025 10:01:33 +0000 (11:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 17 Mar 2025 13:53:36 +0000 (14:53 +0100)
commit557f62593fe3a569819959e735344c0fe1cdb910
tree5164b449d431c46579a1ea6fa5c4132791363537
parentde67f25a7e9223f09cb6d8fe3561d2cbf11037f8
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.
src/cpu_topo.c