Skip to contentSkip to conversation

iwlwifi: mvm: Change an 'else if' into an 'else' in iwl_mvm_send_add_bcast_sta

PATCH In review Nathan Chancellor 3 participants 3 messages Mar 8, 2019 – Mar 11, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iwlwifi: mvm: Change an 'else if' into an 'else' in iwl_mvm_send_add_bcast_sta

When building with -Wsometimes-uninitialized, Clang warns:

drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2114:12: warning: variable 'queue' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Clang can't evaluate at this point that WARN(1, ...) always returns true because __ret_warn_on is defined as !!(condition), which isn't immediately evaluated as 1. Change this branch to else so that it's clear to Clang that we intend to bail out here.

---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/sta.c +3 -1
index 498c315291cf..360724ec41a6 100644
@@ -2111,8 +2111,10 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
 			queue = mvm->probe_queue;
 		else if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
 			queue = mvm->p2p_dev_queue;
-		else if (WARN(1, "Missing required TXQ for adding bcast STA\n"))
+		else {
+			WARN(1, "Missing required TXQ for adding bcast STA\n");
 			return -EINVAL;
+		}
 
 		bsta->tfd_queue_msk |= BIT(queue);
 
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Nathan Chancellor

When building with -Wsometimes-uninitialized, Clang warns:

drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2114:12: warning: variable 'queue' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Quoted 7 lines

Clang can't evaluate at this point that WARN(1, ...) always returns true because __ret_warn_on is defined as !!(condition), which isn't immediately evaluated as 1. Change this branch to else so that it's clear to Clang that we intend to bail out here.

Thanks for the simple fix.

Quoted 23 lines
---
 drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/sta.c +3 -2
index 498c315291cf..360724ec41a6 100644
@@ -2111,8 +2111,10 @@ int iwl_mvm_send_add_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
                        queue = mvm->probe_queue;
                else if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
                        queue = mvm->p2p_dev_queue;
-               else if (WARN(1, "Missing required TXQ for adding bcast STA\n"))
+               else {
+                       WARN(1, "Missing required TXQ for adding bcast STA\n");
                        return -EINVAL;
+               }
 
                bsta->tfd_queue_msk |= BIT(queue);
 
--

2.21.0

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 15 lines · Nick Desaulniers
Quoted 13 lines · Nathan Chancellor

When building with -Wsometimes-uninitialized, Clang warns:

drivers/net/wireless/intel/iwlwifi/mvm/sta.c:2114:12: warning:
variable
'queue' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Clang can't evaluate at this point that WARN(1, ...) always returns true
because __ret_warn_on is defined as !!(condition), which isn't immediately evaluated as 1. Change this branch to else so that it's clear to Clang that we intend to bail out here.

Quoted 5 lines
Quoted 2 lines

Thanks for the simple fix.

Thanks for the patch and for the review!

I have applied it in our internal tree and it will reach the mainline following our normal upstreaming process.

--
Cheers,
Luca.