fix 'and' typo's
PATCH 1/1 fix 'and' typo's
A few patches with changes to net code. I have sent these to the lkml previously, but they were not yet merged. I am fairly new to kernel programming, so it is possible that I make some mistakes. I'll explain my rationale, please nack if incorrect, an additional bit of explanation is appreciated even more.
The condition '!x & y,' does make little sense: the '!' has a higher priority than '&'. It behaves therefore like '!x && y'. In the case bitanding flags, however, '!(x & y)' appears to be desired.
Warning: the change of '!x & y,' to '!(x & y)' may change behavior. if not desired, I propose changing this to '!x && y', to make it explicitly clear.
These '&' typo's can be spotted with:
a="A-Za-z0-9_"
git-grep "\![^$a()]*[$a]\+\([$a.]*\|->\)*\(\[[$a.]*\]\)\?[ \W]*&[^&]\+"
--
Fix priority mistakes similar to '!x & y'
---
drivers/net/wireless/airo.c +1 -1
@@ -6407,7 +6407,7 @@ static int airo_set_encode(struct net_device *dev,set_wep_key (local, index,NULL ,0 , perm,1 ); }else /* Don't complain if only change the mode */ -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {return -EINVAL ; } }
drivers/net/wireless/atmel.c +1 -1
@@ -1759,7 +1759,7 @@ static int atmel_set_encode(struct net_device *dev, priv->default_key = index; }else /* Don't complain if only change the mode */ -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {return -EINVAL ; } }
drivers/net/wireless/libertas/wext.c +1 -1
@@ -1380,7 +1380,7 @@ static int wlan_get_encodeext(struct net_device *dev, index = adapter->wep_tx_keyidx; } -if (!ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY && +if (!(ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY ) && ext->alg !=IW_ENCODE_ALG_WEP ) {if (index !=0 || adapter->mode !=IW_MODE_INFRA ) goto out;
drivers/net/wireless/p54common.c +1 -1
@@ -374,7 +374,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)if ((entry_hdr->magic1 &cpu_to_le16 (0x4000 )) !=0 ) pad = entry_data->align[0 ]; -if (!status.control.flags &IEEE80211_TXCTL_NO_ACK ) { +if (!(status.control.flags &IEEE80211_TXCTL_NO_ACK )) {if (!(payload->status &0x01 )) status.flags |=IEEE80211_TX_STATUS_ACK ;else
drivers/net/wireless/prism54/isl_ioctl.c +2 -2
@@ -1118,7 +1118,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,mgt_set_request (priv,DOT11_OID_DEFKEYID ,0 , &index); }else { -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {/* we cannot do anything. Complain. */ return -EINVAL ; }
@@ -2610,7 +2610,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,mgt_set_request (priv,DOT11_OID_DEFKEYID ,0 , &index); }else { -if (!param->u.crypt.flags &IW_ENCODE_MODE ) { +if (!(param->u.crypt.flags &IW_ENCODE_MODE )) {/* we cannot do anything. Complain. */ return -EINVAL ; }
drivers/net/wireless/zd1211rw/zd_rf_uw2453.c +1 -1
@@ -403,7 +403,7 @@ static int uw2453_init_hw(struct zd_rf *rf)if (r)return r; -if (!intr_status &0xf ) { +if (!(intr_status &0xf )) {dev_dbg_f (zd_chip_dev (chip),"PLL locked on configuration %d\n" , i); found_config = i;
net/ieee80211/ieee80211_wx.c +1 -1
@@ -709,7 +709,7 @@ int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, }else idx = ieee->tx_keyidx; -if (!ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY && +if (!(ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY ) && ext->alg !=IW_ENCODE_ALG_WEP )if (idx !=0 || ieee->iw_mode !=IW_MODE_INFRA )return -EINVAL ;
Quoted 10 lines · Roel Kluin
A few patches with changes to net code. I have sent these to the lkml previously, but they were not yet merged. I am fairly new to kernel programming, so it is possible that I make some mistakes. I'll explain my rationale, please nack if incorrect, an additional bit of explanation is appreciated even more.
The condition '!x & y,' does make little sense: the '!' has a higher priority than '&'. It behaves therefore like '!x && y'. In the case bitanding flags, however, '!(x & y)' appears to be desired.
Quoted 7 lines
Warning: the change of '!x & y,' to '!(x & y)' may change behavior. if not desired, I propose changing this to '!x && y', to make it explicitly clear.
These '&' typo's can be spotted with:
a="A-Za-z0-9_"
git-grep "\![^$a()]*[$a]\+\([$a.]*\|->\)*\(\[[$a.]*\]\)\?[ \W]*&[^&]\+"
It was suggested to split this up, so here goes.
Re: [PATCH split 1/8] fix 'and' typo's in airo wireless
Fix priority mistakes similar to '!x & y' in airo wireless
---
drivers/net/wireless/airo.c +1 -1
@@ -6407,7 +6407,7 @@ static int airo_set_encode(struct net_device *dev,set_wep_key (local, index,NULL ,0 , perm,1 ); }else /* Don't complain if only change the mode */ -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {return -EINVAL ; } }
Re: [PATCH split 2/8] fix 'and' typo's in atmel wireless
In reply to Roel KluinFix priority mistakes similar to '!x & y' in atmel wireless
---
drivers/net/wireless/atmel.c +1 -1
@@ -1759,7 +1759,7 @@ static int atmel_set_encode(struct net_device *dev, priv->default_key = index; }else /* Don't complain if only change the mode */ -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {return -EINVAL ; } }
Re: [PATCH split 3/8] fix 'and' typo's in wireless/libertas/wext
In reply to Roel KluinFix priority mistakes similar to '!x & y' in wireless/libertas/wext
---
drivers/net/wireless/libertas/wext.c +1 -1
@@ -1380,7 +1380,7 @@ static int wlan_get_encodeext(struct net_device *dev, index = adapter->wep_tx_keyidx; } -if (!ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY && +if (!(ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY ) && ext->alg !=IW_ENCODE_ALG_WEP ) {if (index !=0 || adapter->mode !=IW_MODE_INFRA ) goto out;
Re: [PATCH split 4/8] fix 'and' typo's in wireless/p54common
In reply to Roel KluinFix priority mistakes similar to '!x & y' in wireless/p54common
---
drivers/net/wireless/p54common.c +1 -1
@@ -374,7 +374,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)if ((entry_hdr->magic1 &cpu_to_le16 (0x4000 )) !=0 ) pad = entry_data->align[0 ]; -if (!status.control.flags &IEEE80211_TXCTL_NO_ACK ) { +if (!(status.control.flags &IEEE80211_TXCTL_NO_ACK )) {if (!(payload->status &0x01 )) status.flags |=IEEE80211_TX_STATUS_ACK ;else
Re: [PATCH split 5/8] fix 'and' typo's wireless/prism54/isl_ioctl (first)
In reply to Roel KluinFix priority mistakes similar to '!x & y' wireless/prism54/isl_ioctl (first)
---
drivers/net/wireless/prism54/isl_ioctl.c +1 -1
@@ -1118,7 +1118,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,mgt_set_request (priv,DOT11_OID_DEFKEYID ,0 , &index); }else { -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {/* we cannot do anything. Complain. */ return -EINVAL ; }
Luis R. Rodriguez
Acked-byRe: [PATCH split 5/8] fix 'and' typo's wireless/prism54/isl_ioctl (first)
Quoted 3 lines · Roel Kluin
Fix priority mistakes similar to '!x & y' wireless/prism54/isl_ioctl (first)
Signed-off-by Roel Kluin <[email protected]>
Thanks,
Luis
could be an error due to the splitting, of this and the former patch? Then reply for another one.
--
Fix priority mistakes similar to '!x & y'
---
drivers/net/wireless/prism54/isl_ioctl.c +1 -1
@@ -2610,7 +2610,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,mgt_set_request (priv,DOT11_OID_DEFKEYID ,0 , &index); }else { -if (!param->u.crypt.flags &IW_ENCODE_MODE ) { +if (!(param->u.crypt.flags &IW_ENCODE_MODE )) {/* we cannot do anything. Complain. */ return -EINVAL ; }
Re: [PATCH split 7/8] fix 'and' typo's in wireless/zd1211rw/zd_rf_uw2453
In reply to Roel KluinFix priority mistakes similar to '!x & y'
---
drivers/net/wireless/zd1211rw/zd_rf_uw2453.c +1 -1
@@ -403,7 +403,7 @@ static int uw2453_init_hw(struct zd_rf *rf)if (r)return r; -if (!intr_status &0xf ) { +if (!(intr_status &0xf )) {dev_dbg_f (zd_chip_dev (chip),"PLL locked on configuration %d\n" , i); found_config = i;
Re: [PATCH split 8/8] fix 'and' typo's net/ieee80211/ieee80211_wx
In reply to Roel KluinFix priority mistakes similar to '!x & y'
---
net/ieee80211/ieee80211_wx.c +1 -1
@@ -709,7 +709,7 @@ int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, }else idx = ieee->tx_keyidx; -if (!ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY && +if (!(ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY ) && ext->alg !=IW_ENCODE_ALG_WEP )if (idx !=0 || ieee->iw_mode !=IW_MODE_INFRA )return -EINVAL ;
PATCH 1/1 Replace logical- by bit-and
In reply to Roel KluinTotally untested patch below from linus' git tree. The && is incorrect, right?
from drivers/net/wireless/arlan.h:390:
#define ARLAN_POWER 0x40
#define ARLAN_ACCESS 0x80
Replace logical and by bit-and
---
drivers/net/wireless/arlan.h +1 -1
@@ -485,7 +485,7 @@ struct arlan_private {#define clearClearInterrupt (dev){\ writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_CLEAR_INTERRUPT);}#define setPowerOff (dev){\ - writeControlRegister(dev,readControlRegister(dev) | (ARLAN_POWER && ARLAN_ACCESS));\ + writeControlRegister(dev, readControlRegister(dev) | (ARLAN_POWER & ARLAN_ACCESS));\ writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_ACCESS);}#define setPowerOn (dev){\ writeControlRegister(dev,readControlRegister(dev) & ~(ARLAN_POWER)); }
Re: [PATCH wireless/arlan] Replace logical- by bit-and
Quoted 15 lines · On Thu, 10 Jan 2008 20:15:53 +0100 Roel Kluin wrote:
Totally untested patch below from linus' git tree. The && is incorrect, right?
from
drivers/net/wireless/arlan.h:390:
#defineARLAN_POWER0x40
#defineARLAN_ACCESS0x80Replace logical and by bit-and
Signed-off-by Roel Kluin <[email protected]>---
drivers/net/wireless/arlan.h +0
-0
drivers/net/wireless/arlan.h struct arlan_private { · line 488
Quoted 5 lines
drivers/net/wireless/arlan.h +1
-1@@ -485,7 +485,7 @@ struct arlan_private {#define clearClearInterrupt (dev){\ writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_CLEAR_INTERRUPT);}#define setPowerOff (dev){\ - writeControlRegister(dev,readControlRegister(dev) | (ARLAN_POWER && ARLAN_ACCESS));\ + writeControlRegister(dev, readControlRegister(dev) | (ARLAN_POWER & ARLAN_ACCESS));\
eh? How does that help?
0x80 && 0x40 -> 00x80 & 0x40 -> 0
so readControlRegister() | (0)
??
Maybe it should be (ARLAN_POWER | ARLAN_ACCESS), but some arlan developer or someone with specs should help here...
drivers/net/wireless/arlan.h struct arlan_private { · line 491
Quoted 3 lines
drivers/net/wireless/arlan.h +0
-0writeControlRegister (dev,readControlRegister (dev) & ~ARLAN_ACCESS );}#define setPowerOn (dev){\ writeControlRegister(dev,readControlRegister(dev) & ~(ARLAN_POWER)); }
or am I sleeping()?
---
~Randy
Re: [PATCH wireless/arlan] Replace logical- by bit-and
Quoted 25 lines · Randy Dunlap
Quoted 15 lines · On Thu, 10 Jan 2008 20:15:53 +0100 Roel Kluin wrote:
Totally untested patch below from linus' git tree. The && is incorrect, right?
from
drivers/net/wireless/arlan.h:390:
#defineARLAN_POWER0x40
#defineARLAN_ACCESS0x80Replace logical and by bit-and
Signed-off-by Roel Kluin <[email protected]>---
drivers/net/wireless/arlan.h +0
-0drivers/net/wireless/arlan.h struct arlan_private { · line 488
Quoted 5 lines
drivers/net/wireless/arlan.h +1
-1@@ -485,7 +485,7 @@ struct arlan_private {#define clearClearInterrupt (dev){\ writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_CLEAR_INTERRUPT);}#define setPowerOff (dev){\ - writeControlRegister(dev,readControlRegister(dev) | (ARLAN_POWER && ARLAN_ACCESS));\ + writeControlRegister(dev, readControlRegister(dev) | (ARLAN_POWER & ARLAN_ACCESS));\eh? How does that help?
Quoted 1 line
0x80&&0x40-> 0
1
Re: [PATCH wireless/arlan] Replace logical- by bit-and
Quoted 6 lines · Chuck Ebbert
Quoted 2 lines · Randy Dunlap
0x80&&0x40-> 01
duh. ack.
Signature · 1 line
~Randy
Re: [PATCH wireless/arlan] Replace logical- by bit-and
Quoted 9 lines · Randy Dunlap
Quoted 6 lines · Chuck Ebbert
Quoted 2 lines · Randy Dunlap
0x80&&0x40-> 01
duh. ack.
Well it still seems wrong, changing from an "| 1" to an "| 0". Anyone still using Arlan that can verify the proper fix (which I'd guess is changing "&&" to "|")?
John
Signature · 2 lines
John W. Linville [email protected]
Re: [PATCH wireless/arlan] Replace logical- by bit-and
In reply to Randy DunlapQuoted 14 lines · Randy Dunlap
drivers/net/wireless/arlan.h struct arlan_private { · line 488
Quoted 10 lines · On Thu, 10 Jan 2008 20:15:53 +0100 Roel Kluin wrote:
drivers/net/wireless/arlan.h +1
-1@@ -485,7 +485,7 @@ struct arlan_private {#define clearClearInterrupt (dev){\ writeControlRegister(dev,readControlRegister(dev) & ~ARLAN_CLEAR_INTERRUPT);}#define setPowerOff (dev){\ - writeControlRegister(dev,readControlRegister(dev) | (ARLAN_POWER && ARLAN_ACCESS));\ + writeControlRegister(dev, readControlRegister(dev) | (ARLAN_POWER & ARLAN_ACCESS));\eh? How does that help?
Right, sorry, please ignore my patch.
Quoted 2 lines
Maybe it should be (
ARLAN_POWER|ARLAN_ACCESS), but some arlan developer or someone with specs should help here...
I have CC'd the previous maintainers
Quoted 28 lines · Roel Kluin
A few patches with changes to net code. I have sent these to the lkml previously, but they were not yet merged. I am fairly new to kernel programming, so it is possible that I make some mistakes. I'll explain my rationale, please nack if incorrect, an additional bit of explanation is appreciated even more.
The condition '!x & y,' does make little sense: the '!' has a higher priority than '&'. It behaves therefore like '!x && y'. In the case bitanding flags, however, '!(x & y)' appears to be desired.
Warning: the change of '!x & y,' to '!(x & y)' may change behavior. if not desired, I propose changing this to '!x && y', to make it explicitly clear.
These '&' typo's can be spotted with:
a="A-Za-z0-9_"
git-grep "\![^$a()]*[$a]\+\([$a.]*\|->\)*\(\[[$a.]*\]\)\?[ \W]*&[^&]\+"--
Fix priority mistakes similar to '!x & y'Signed-off-by Roel Kluin <[email protected]>---
drivers/net/wireless/airo.c +0
-0
drivers/net/wireless/airo.c static int airo_set_encode(struct net_device *dev, · line 6413
Quoted 8 lines
drivers/net/wireless/airo.c +1
-1@@ -6407,7 +6407,7 @@ static int airo_set_encode(struct net_device *dev,set_wep_key (local, index,NULL ,0 , perm,1 ); }else /* Don't complain if only change the mode */ -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {return -EINVAL ; } }
Ack.
drivers/net/wireless/atmel.c static int atmel_set_encode(struct net_device *dev, · line 1765
Quoted 13 lines
drivers/net/wireless/atmel.c +1
-1@@ -1759,7 +1759,7 @@ static int atmel_set_encode(struct net_device *dev, priv->default_key = index; }else /* Don't complain if only change the mode */ -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {return -EINVAL ; } }
Ack.
drivers/net/wireless/libertas/wext.c static int wlan_get_encodeext(struct net_device *dev, · line 1386
Quoted 13 lines
drivers/net/wireless/libertas/wext.c +1
-1@@ -1380,7 +1380,7 @@ static int wlan_get_encodeext(struct net_device *dev, index = adapter->wep_tx_keyidx; } -if (!ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY && +if (!(ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY ) && ext->alg !=IW_ENCODE_ALG_WEP ) {if (index !=0 || adapter->mode !=IW_MODE_INFRA ) goto out;
Ack.
Quoted 65 lines
drivers/net/wireless/p54common.c +1
-1@@ -374,7 +374,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)if ((entry_hdr->magic1 &cpu_to_le16 (0x4000 )) !=0 ) pad = entry_data->align[0 ]; -if (!status.control.flags &IEEE80211_TXCTL_NO_ACK ) { +if (!(status.control.flags &IEEE80211_TXCTL_NO_ACK )) {if (!(payload->status &0x01 )) status.flags |=IEEE80211_TX_STATUS_ACK ;else drivers/net/wireless/prism54/isl_ioctl.c +2
-2@@ -1118,7 +1118,7 @@ prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,mgt_set_request (priv,DOT11_OID_DEFKEYID ,0 , &index); }else { -if (!dwrq->flags &IW_ENCODE_MODE ) { +if (!(dwrq->flags &IW_ENCODE_MODE )) {/* we cannot do anything. Complain. */ return -EINVAL ; }@@ -2610,7 +2610,7 @@ prism2_ioctl_set_encryption(struct net_device *dev,mgt_set_request (priv,DOT11_OID_DEFKEYID ,0 , &index); }else { -if (!param->u.crypt.flags &IW_ENCODE_MODE ) { +if (!(param->u.crypt.flags &IW_ENCODE_MODE )) {/* we cannot do anything. Complain. */ return -EINVAL ; }drivers/net/wireless/zd1211rw/zd_rf_uw2453.c +1
-1@@ -403,7 +403,7 @@ static int uw2453_init_hw(struct zd_rf *rf)if (r)return r; -if (!intr_status &0xf ) { +if (!(intr_status &0xf )) {dev_dbg_f (zd_chip_dev (chip),"PLL locked on configuration %d\n" , i); found_config = i;net/ieee80211/ieee80211_wx.c +1
-2@@ -709,7 +709,7 @@ int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, }else idx = ieee->tx_keyidx; -if (!ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY && +if (!(ext->ext_flags &IW_ENCODE_EXT_GROUP_KEY ) && ext->alg !=IW_ENCODE_ALG_WEP )if (idx !=0 || ieee->iw_mode !=IW_MODE_INFRA )return -EINVAL ; -To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Dan Williams
drivers/net/wireless/airo.c
Quoted 3 lines
drivers/net/wireless/airo.c +0
-1--- a/drivers/net/wireless/airo.cAck.
drivers/net/wireless/atmel.c
Quoted 3 lines
drivers/net/wireless/atmel.c +0
-1--- a/drivers/net/wireless/atmel.cAck.
Quoted 7 lines
drivers/net/wireless/libertas/wext.c
Quoted 3 lines
drivers/net/wireless/libertas/wext.c +0
-1--- a/drivers/net/wireless/libertas/wext.cAck.
Thanks.
I have sent them as separate patches to the wireless list as well.