kern ath drivers: Fix loops bounds (real bug x2) + source
authorJohn Marino <draco@marino.st>
Wed, 11 Feb 2015 01:59:18 +0000 (02:59 +0100)
committerJohn Marino <draco@marino.st>
Wed, 11 Feb 2015 02:00:27 +0000 (03:00 +0100)
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
sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c
sys/dev/netif/ath/ath_hal/ah_eeprom_v4k.c

index 75746fc..fffb029 100644 (file)
@@ -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");
index abdbce0..99173bf 100644 (file)
@@ -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;
index 12cb67e..f934dcc 100644 (file)
@@ -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;