mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 07:04:24 +00:00
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/ Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Link: https://lore.kernel.org/r/20220324073024.65943-1-jakobkoschel@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
9619a47f7e
commit
66f663a294
2 changed files with 12 additions and 14 deletions
|
@ -918,8 +918,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)
|
||||
|
@ -930,16 +929,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) {
|
||||
|
|
|
@ -289,8 +289,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;
|
||||
|
@ -309,16 +308,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;
|
||||
|
|
Loading…
Reference in a new issue