[PATCH] examples/vm_power: replace list foreach with while loop

Shibin Koikkara Reeny shibin.koikkara.reeny at intel.com
Tue Mar 1 15:53:13 CET 2022


Linux header files don't support LIST_FOREACH_SAFE so replacing
LIST_FOREACH with while loop.

Fixes: e8ae9b662506 ("examples/vm_power: channel manager and monitor in host")
Cc: alan.carew at intel.com
Cc: stable at dpdk.org

Signed-off-by: Shibin Koikkara Reeny <shibin.koikkara.reeny at intel.com>
---
 examples/vm_power_manager/channel_manager.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
index 838465ab4b..b4dea4b275 100644
--- a/examples/vm_power_manager/channel_manager.c
+++ b/examples/vm_power_manager/channel_manager.c
@@ -1005,10 +1005,10 @@ channel_manager_exit(void)
 {
 	unsigned i;
 	char mask[RTE_MAX_LCORE];
-	struct virtual_machine_info *vm_info;
-
-	LIST_FOREACH(vm_info, &vm_list_head, vms_info) {
+	struct virtual_machine_info *vm_info = LIST_FIRST(&vm_list_head);
 
+	/* No LIST_FOREACH_SAFE, using while instead. */
+	while (vm_info) {
 		rte_spinlock_lock(&(vm_info->config_spinlock));
 
 		memcpy(mask, (char *)vm_info->channel_mask, RTE_MAX_LCORE);
@@ -1024,6 +1024,8 @@ channel_manager_exit(void)
 
 		LIST_REMOVE(vm_info, vms_info);
 		rte_free(vm_info);
+
+		vm_info = LIST_NEXT((vm_info), vms_info);
 	}
 
 	if (global_hypervisor_available) {
-- 
2.25.1



More information about the stable mailing list