error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]

在使用MT7628芯片时,下载的工程编译后自带的wifi驱动不能正常运行,手机搜索不到对应WIFI。

工程文件:mtk-openwrt-sdk-20151231-185ab215.tar.bz2
下载路径:https://www.openwrtdl.com/wordpress/?s=7628

因此又从网络上寻找最新的MT7628 WIFI驱动:

MT7628_LinuxAP_V4.1.0.0_DPA_20161216.rar

将此驱动添加进下载的工程中,编译出现以下错误:

/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c: In function 'NewRateAdaptMT':
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:839:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
     ^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:840:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
     ^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:935:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
     ^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:936:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
     ^
cc1: all warnings being treated as errors
scripts/Makefile.build:308: recipe for target '/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.o' failed
make[5]: *** [/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.o] Error 1
Makefile:1224: recipe for target '_module_/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build/' failed
make[4]: *** [_module_/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build/] Error 2
make[4]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/linux-3.10.14'
Makefile:86: recipe for target '/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/.built' failed
make[3]: *** [/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/.built] Error 2
make[3]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk/package/ramips/drivers/mt7628'
package/Makefile:173: recipe for target 'package/ramips/drivers/mt7628/compile' failed
make[2]: *** [package/ramips/drivers/mt7628/compile] Error 2
make[2]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk'
package/Makefile:170: recipe for target '/home/lc/openwrt_mtk/openwrt-sdk/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.package_compile' failed
make[1]: *** [/home/lc/openwrt_mtk/openwrt-sdk/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/lc/openwrt_mtk/openwrt-sdk'
/home/lc/openwrt_mtk/openwrt-sdk/include/toplevel.mk:171: recipe for target 'world' failed
make: *** [world] Error 2

从以上信息中我们可以清晰的知道错误发生的位置:

190515/build//../src/embedded/../rate_ctrl/alg_grp.c:839:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
     ^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:840:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
     ^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:935:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
     ^
/home/lc/openwrt_mtk/openwrt-sdk/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7628/mt7628-p4rev-190515/build//../src/embedded/../rate_ctrl/alg_grp.c:936:5: error: suggest parentheses around comparison in operand of '&' [-Werror=parentheses]
     ((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
     ^
cc1: all warnings being treated as errors

关键错误信息: error: suggest parentheses around comparison in operand of ‘&’ [-Werror=parentheses]
原因分析:
该警告希望你在&(逻辑与)表达式左右加上括号。有的时候&&(逻辑且)少写了一个&,也会产生该警告。
例如:
if((a[2]>>1)&0x1 == 1){

}
应该将 (a[2]>>1)&0x1 用()号括起来。因为&运算符的优先级较低,低于==和!=运算符。

于是找到相应错误代码(839行,840行,935行和936行),
修改前:


/*Ivan Lee add add for 360  promote middle sta performance*/
/*If B/G/N MIX Mode but pCurrTxRate <= MCS_3, ,not drop rate*/
/*If B/G MIX Mode but pCurrTxRate <= MCS_3 ,not drop rate*/
if( (Rssi > pAd->CommonCfg.MidRssiSet) && ( 
	((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
	((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE)==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
{
......
......

修改后

/*Ivan Lee add add for 360  promote middle sta performance*/
/*If B/G/N MIX Mode but pCurrTxRate <= MCS_3, ,not drop rate*/
/*If B/G MIX Mode but pCurrTxRate <= MCS_3 ,not drop rate*/
if( (Rssi > pAd->CommonCfg.MidRssiSet) && ( 
    (((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE))==0x07)&&((CurrRateIdx <= MCS_3)||(pCurrTxRate->Mode==MODE_OFDM)||(pCurrTxRate->Mode==MODE_CCK)))|| /* B/G/N MIX Mode */
	(((pEntry->SupportRateMode&(SUPPORT_HT_MODE|SUPPORT_OFDM_MODE|SUPPORT_CCK_MODE))==0x03)&&(CurrRateIdx <= MCS_3))/* B/G MIX Mode*/) )
{
.....
.....

PS:
在这里插入图片描述在这里插入图片描述在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值