* False warning from Sparse
@ 2012-07-22 3:52 Larry Finger
2012-07-22 4:44 ` Josh Triplett
0 siblings, 1 reply; 2+ messages in thread
From: Larry Finger @ 2012-07-22 3:52 UTC (permalink / raw)
To: Christopher Li; +Cc: Linux-Sparse, linux-kernel
Hi,
I am getting the following false warning from sparse:
CHECK drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c:1158:13: warning: context
imbalance in 'rtl92c_dm_refresh_rate_adaptive_mask' - different lock contexts
for basic block
The only code in that routine that does any locking is the following:
/* Only the PCI card uses sta in the update rate table
* callback routine */
if (rtlhal->interface == INTF_PCI) {
rcu_read_lock();
sta = ieee80211_find_sta(mac->vif, mac->bssid);
}
rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
p_ra->ratr_state);
p_ra->pre_ratr_state = p_ra->ratr_state;
if (rtlhal->interface == INTF_PCI)
rcu_read_unlock();
Does the warning get output because the code cannot assume that
rtlhal->interface is the same in both if statements? If that is the case, are
there any compiler directives that would tell sparse of the situation?
Thanks,
Larry
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: False warning from Sparse
2012-07-22 3:52 False warning from Sparse Larry Finger
@ 2012-07-22 4:44 ` Josh Triplett
0 siblings, 0 replies; 2+ messages in thread
From: Josh Triplett @ 2012-07-22 4:44 UTC (permalink / raw)
To: Larry Finger; +Cc: Christopher Li, Linux-Sparse, linux-kernel
On Sat, Jul 21, 2012 at 10:52:54PM -0500, Larry Finger wrote:
> I am getting the following false warning from sparse:
>
> CHECK drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
> drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c:1158:13: warning:
> context imbalance in 'rtl92c_dm_refresh_rate_adaptive_mask' -
> different lock contexts for basic block
>
> The only code in that routine that does any locking is the following:
>
> /* Only the PCI card uses sta in the update rate table
> * callback routine */
> if (rtlhal->interface == INTF_PCI) {
> rcu_read_lock();
> sta = ieee80211_find_sta(mac->vif, mac->bssid);
> }
> rtlpriv->cfg->ops->update_rate_tbl(hw, sta,
> p_ra->ratr_state);
>
> p_ra->pre_ratr_state = p_ra->ratr_state;
> if (rtlhal->interface == INTF_PCI)
> rcu_read_unlock();
>
> Does the warning get output because the code cannot assume that
> rtlhal->interface is the same in both if statements?
Correct; sparse does not have enough dataflow analysis to connect the
two if bodies, nor can it verify that nothing between the two changes
rtlhal->interface.
> If that is the
> case, are there any compiler directives that would tell sparse of
> the situation?
No, none of Sparse's directives will let you override this. However,
you could do something like the following:
/* Only the PCI card uses sta in the update rate table
* callback routine */
if (rtlhal->interface == INTF_PCI) {
rcu_read_lock();
sta = ieee80211_find_sta(mac->vif, mac->bssid);
rtlpriv->cfg->ops->update_rate_tbl(hw, sta, p_ra->ratr_state);
p_ra->pre_ratr_state = p_ra->ratr_state;
rcu_read_unlock();
} else {
rtlpriv->cfg->ops->update_rate_tbl(hw, sta, p_ra->ratr_state);
p_ra->pre_ratr_state = p_ra->ratr_state;
}
You could wrap those two lines in a function if you don't want to
duplicate them.
If that solution or a similar refactoring doesn't appeal to you, then
you don't currently have any way of making that context warning go away,
short of improving Sparse to handle this situation better.
- Josh Triplett
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-22 4:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-22 3:52 False warning from Sparse Larry Finger
2012-07-22 4:44 ` Josh Triplett
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).