To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@xxxxxxxxxxxxxx/ Signed-off-by: Jakob Koschel <jakobkoschel@xxxxxxxxx> --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 13 ++++++------- .../vc04_services/interface/vchiq_arm/vchiq_dev.c | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3a2e4582db8e..f27ff246a672 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -908,8 +908,7 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, struct vchiq_instance *instance; struct vchiq_service *service; enum vchiq_status status; - struct bulk_waiter_node *waiter = NULL; - bool found = false; + struct bulk_waiter_node *waiter = NULL, *iter; service = find_service_by_handle(handle); if (!service) @@ -920,16 +919,16 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, vchiq_service_put(service); mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each_entry(waiter, &instance->bulk_waiter_list, list) { - if (waiter->pid == current->pid) { - list_del(&waiter->list); - found = true; + list_for_each_entry(iter, &instance->bulk_waiter_list, list) { + if (iter->pid == current->pid) { + list_del(&iter->list); + waiter = iter; break; } } mutex_unlock(&instance->bulk_waiter_list_mutex); - if (found) { + if (waiter) { struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk; if (bulk) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c index 2325844b0880..5102750dbabc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -290,8 +290,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, enum vchiq_bulk_mode __user *mode) { struct vchiq_service *service; - struct bulk_waiter_node *waiter = NULL; - bool found = false; + struct bulk_waiter_node *waiter = NULL, *iter; void *userdata; int status = 0; int ret; @@ -310,16 +309,16 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, userdata = &waiter->bulk_waiter; } else if (args->mode == VCHIQ_BULK_MODE_WAITING) { mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each_entry(waiter, &instance->bulk_waiter_list, + list_for_each_entry(iter, &instance->bulk_waiter_list, list) { - if (waiter->pid == current->pid) { - list_del(&waiter->list); - found = true; + if (iter->pid == current->pid) { + list_del(&iter->list); + waiter = iter; break; } } mutex_unlock(&instance->bulk_waiter_list_mutex); - if (!found) { + if (!waiter) { vchiq_log_error(vchiq_arm_log_level, "no bulk_waiter found for pid %d", current->pid); ret = -ESRCH; base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1