From 35f41e5c57e3b0c25ba342b7605756c251f6cce6 Mon Sep 17 00:00:00 2001 From: John Marino Date: Wed, 11 Feb 2015 02:59:18 +0100 Subject: [PATCH] kern ath drivers: Fix loops bounds (real bug x2) + source The ar9300 source had a couple of logic ambiguities causing [-Werror=logical-not-parenthesis] warnings. The other two used the wrong variable for the upper bounds of the loop. I assume it was correct once but the code changed, and the author neglected to use the next edges max value. --- sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c | 4 ++-- sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c | 4 ++-- sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c index 75746fc724..fffb02944d 100644 --- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c +++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_ani.c @@ -539,7 +539,7 @@ skip_ws_det: OS_REG_CLR_BIT(ah, AR_PHY_SFCORR_LOW, AR_PHY_SFCORR_LOW_USE_SELF_CORR_LOW); } - if (!is_on != ani_state->ofdm_weak_sig_detect_off) { + if (!(is_on != ani_state->ofdm_weak_sig_detect_off)) { HALDEBUG(ah, HAL_DEBUG_ANI, "%s: ** ch %d: ofdm weak signal: %s=>%s\n", __func__, chan->ic_freq, @@ -684,7 +684,7 @@ skip_ws_det: OS_REG_RMW_FIELD(ah, AR_PHY_MRC_CCK_CTRL, AR_PHY_MRC_CCK_MUX_REG, is_on); } - if (!is_on != ani_state->mrc_cck_off) { + if (!(is_on != ani_state->mrc_cck_off)) { HALDEBUG(ah, HAL_DEBUG_ANI, "%s: ** ch %d: MRC CCK: %s=>%s\n", __func__, chan->ic_freq, !ani_state->mrc_cck_off ? "on" : "off", is_on ? "on" : "off"); diff --git a/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c b/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c index abdbce0564..99173bfa50 100644 --- a/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c +++ b/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c @@ -248,8 +248,8 @@ v9287EepromReadCTLInfo(struct ath_hal *ah, HAL_EEPROM_9287 *ee) HALASSERT(AR9287_NUM_CTLS <= sizeof(ee->ee_rdEdgesPower)/NUM_EDGES); - for (i = 0; ee->ee_base.ctlIndex[i] != 0 && i < AR9287_NUM_CTLS; i++) { - for (j = 0; j < NUM_EDGES; j ++) { + for (i = 0; i < AR9287_NUM_CTLS && ee->ee_base.ctlIndex[i] != 0 ; i++) { + for (j = 0; j < AR9287_NUM_BAND_EDGES; j++) { /* XXX Confirm this is the right thing to do when an invalid channel is stored */ if (ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel == AR5416_BCHAN_UNUSED) { rep[j].rdEdge = 0; diff --git a/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c b/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c index 12cb67e437..f934dcc691 100644 --- a/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c +++ b/sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c @@ -237,8 +237,8 @@ v4kEepromReadCTLInfo(struct ath_hal *ah, HAL_EEPROM_v4k *ee) HALASSERT(AR5416_4K_NUM_CTLS <= sizeof(ee->ee_rdEdgesPower)/NUM_EDGES); - for (i = 0; ee->ee_base.ctlIndex[i] != 0 && i < AR5416_4K_NUM_CTLS; i++) { - for (j = 0; j < NUM_EDGES; j ++) { + for (i = 0; i < AR5416_4K_NUM_CTLS && ee->ee_base.ctlIndex[i] != 0; i++) { + for (j = 0; j < AR5416_4K_NUM_BAND_EDGES; j++) { /* XXX Confirm this is the right thing to do when an invalid channel is stored */ if (ee->ee_base.ctlData[i].ctlEdges[CTL_CHAIN][j].bChannel == AR5416_BCHAN_UNUSED) { rep[j].rdEdge = 0; -- 2.41.0