From fbcbb4e208eb5d344131ae074caafa84fa24de30 Mon Sep 17 00:00:00 2001 From: Li Zhijian Date: Tue, 12 Nov 2024 16:52:16 +0800 Subject: [PATCH] providers/mlx5: Fix warning: 'prev' may be used uninitialized 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 --- providers/mlx5/dr_vports.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/mlx5/dr_vports.c b/providers/mlx5/dr_vports.c index 963b327d1..a9d95623d 100644 --- a/providers/mlx5/dr_vports.c +++ b/providers/mlx5/dr_vports.c @@ -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;