staging: vchiq: replace usage of found with dedicated list iterator variable
Subsystems (2)
PATCH 1/1 staging: vchiq: replace usage of found with dedicated list iterator variable
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@mail.gmail.com/ open here
Signed-off-by Jakob Koschel <[email protected]>
--- .../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(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +6 -7
@@ -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) {
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c +6 -7
@@ -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
Signature · 1 line
2.25.1