* [PATCH] iwlwifi: mvm: replace usage of found with dedicated list iterator variable
@ 2022-03-24 7:11 Jakob Koschel
0 siblings, 0 replies; only message in thread
From: Jakob Koschel @ 2022-03-24 7:11 UTC (permalink / raw)
To: Luca Coelho
Cc: Kalle Valo, David S. Miller, Jakub Kicinski, Paolo Abeni,
Avraham Stern, Miri Korenblit, Johannes Berg, Nathan Chancellor,
Shaul Triebitz, Ilan Peer, Emmanuel Grumbach, Sara Sharon,
Nathan Errera, linux-wireless, netdev, linux-kernel,
Mike Rapoport, Brian Johannesmeyer, Cristiano Giuffrida, Bos,
H.J.,
Jakob Koschel
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>
---
.../net/wireless/intel/iwlwifi/mvm/ftm-initiator.c | 12 +++++-------
drivers/net/wireless/intel/iwlwifi/mvm/time-event.c | 11 +++++------
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
index 628aee634b2a..67a03fcde759 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ftm-initiator.c
@@ -1011,11 +1011,10 @@ static int iwl_mvm_ftm_range_resp_valid(struct iwl_mvm *mvm, u8 request_id,
static void iwl_mvm_ftm_rtt_smoothing(struct iwl_mvm *mvm,
struct cfg80211_pmsr_result *res)
{
- struct iwl_mvm_smooth_entry *resp;
+ struct iwl_mvm_smooth_entry *resp = NULL, *iter;
s64 rtt_avg, rtt = res->ftm.rtt_avg;
u32 undershoot, overshoot;
u8 alpha;
- bool found;
if (!IWL_MVM_FTM_INITIATOR_ENABLE_SMOOTH)
return;
@@ -1029,15 +1028,14 @@ static void iwl_mvm_ftm_rtt_smoothing(struct iwl_mvm *mvm,
return;
}
- found = false;
- list_for_each_entry(resp, &mvm->ftm_initiator.smooth.resp, list) {
- if (!memcmp(res->addr, resp->addr, ETH_ALEN)) {
- found = true;
+ list_for_each_entry(iter, &mvm->ftm_initiator.smooth.resp, list) {
+ if (!memcmp(res->addr, iter->addr, ETH_ALEN)) {
+ resp = iter;
break;
}
}
- if (!found) {
+ if (!resp) {
resp = kzalloc(sizeof(*resp), GFP_KERNEL);
if (!resp)
return;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c b/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
index ab06dcda1462..98e91231cc20 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c
@@ -377,16 +377,15 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
static int iwl_mvm_aux_roc_te_handle_notif(struct iwl_mvm *mvm,
struct iwl_time_event_notif *notif)
{
- struct iwl_mvm_time_event_data *te_data, *tmp;
- bool aux_roc_te = false;
+ struct iwl_mvm_time_event_data *te_data = NULL, *iter, *tmp;
- list_for_each_entry_safe(te_data, tmp, &mvm->aux_roc_te_list, list) {
- if (le32_to_cpu(notif->unique_id) == te_data->uid) {
- aux_roc_te = true;
+ list_for_each_entry_safe(iter, tmp, &mvm->aux_roc_te_list, list) {
+ if (le32_to_cpu(notif->unique_id) == iter->uid) {
+ te_data = iter;
break;
}
}
- if (!aux_roc_te) /* Not a Aux ROC time event */
+ if (!te_data) /* Not a Aux ROC time event */
return -EINVAL;
iwl_mvm_te_check_trigger(mvm, notif, te_data);
base-commit: f443e374ae131c168a065ea1748feac6b2e76613
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-24 7:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 7:11 [PATCH] iwlwifi: mvm: replace usage of found with dedicated list iterator variable Jakob Koschel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).