Commit 4302005f authored by Jakob Koschel's avatar Jakob Koschel Committed by Jason Gunthorpe

IB/SA: 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.

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/r/20220331091634.644840-1-jakobkoschel@gmail.comReviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
Signed-off-by: default avatarJakob Koschel <jakobkoschel@gmail.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent e945c653
...@@ -1034,10 +1034,9 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb, ...@@ -1034,10 +1034,9 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
unsigned long flags; unsigned long flags;
struct ib_sa_query *query; struct ib_sa_query *query = NULL, *iter;
struct ib_mad_send_buf *send_buf; struct ib_mad_send_buf *send_buf;
struct ib_mad_send_wc mad_send_wc; struct ib_mad_send_wc mad_send_wc;
int found = 0;
int ret; int ret;
if ((nlh->nlmsg_flags & NLM_F_REQUEST) || if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
...@@ -1045,20 +1044,21 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb, ...@@ -1045,20 +1044,21 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb,
return -EPERM; return -EPERM;
spin_lock_irqsave(&ib_nl_request_lock, flags); spin_lock_irqsave(&ib_nl_request_lock, flags);
list_for_each_entry(query, &ib_nl_request_list, list) { list_for_each_entry(iter, &ib_nl_request_list, list) {
/* /*
* If the query is cancelled, let the timeout routine * If the query is cancelled, let the timeout routine
* take care of it. * take care of it.
*/ */
if (nlh->nlmsg_seq == query->seq) { if (nlh->nlmsg_seq == iter->seq) {
found = !ib_sa_query_cancelled(query); if (!ib_sa_query_cancelled(iter)) {
if (found) list_del(&iter->list);
list_del(&query->list); query = iter;
}
break; break;
} }
} }
if (!found) { if (!query) {
spin_unlock_irqrestore(&ib_nl_request_lock, flags); spin_unlock_irqrestore(&ib_nl_request_lock, flags);
goto resp_out; goto resp_out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment