Skip to content

Commit

Permalink
providers/mlx5: Fix warning: 'prev' may be used uninitialized
Browse files Browse the repository at this point in the history
This patch addresses a compiler warning indicating that the 'prev'
variable may be used uninitialized in the function
dr_vports_table_del_wire. Although this warning is a false positive,
it is important to resolve it to prevent potential confusion and
maintain code quality.

The 'while (vport)' loop is intended to start from the second element
of the linked list, as the first element is already checked by a
preceding condition. By initializing 'prev' to the first element
and 'vport' to 'prev->next', we ensure that the loop logic remains
correct and the warning is eliminated.

This change does not alter the functionality of the code but enhances
its clarity and robustness by ensuring all variables are properly
initialized before use.

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
  • Loading branch information
zhijianli88 committed Nov 13, 2024
1 parent 423f8a1 commit fbcbb4e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion providers/mlx5/dr_vports.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ void dr_vports_table_del_wire(struct dr_devx_vports *vports)
goto out_unlock;
}

vport = h->buckets[idx];
prev = h->buckets[idx];
vport = prev->next;
while (vport) {
if (vport == wire) {
prev->next = vport->next;
Expand Down

0 comments on commit fbcbb4e

Please # to comment.