From c135dc326c0db4abe978e0f949b53c97e4a83157 Mon Sep 17 00:00:00 2001 From: proski Date: Wed, 8 Apr 2009 08:52:59 +0000 Subject: [PATCH] Simplify linker set implementation, fix compiler warning with -O3 gcc warns that "array subscript is above array bounds" with -O3 since pvar is assigned before _i is checked. Eliminate _i, use a new ppvar variable, which is a pointer to the reference table. Terminate reference tables with NULL instead of using ARRAY_SIZE. Fix types of reference tables to match those actually used by the code. git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@3987 0192ed92-7a03-0410-a25b-9323aeb14dbd --- ath_hal/ah_osdep.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ath_hal/ah_osdep.h b/ath_hal/ah_osdep.h index b74f880..8dca6bc 100644 --- a/ath_hal/ah_osdep.h +++ b/ath_hal/ah_osdep.h @@ -66,13 +66,14 @@ struct ath_hal_chip *AR5212_chip_ptr __attribute__((__weak__)); \ struct ath_hal_chip *AR5312_chip_ptr __attribute__((__weak__)); \ struct ath_hal_chip *AR5416_chip_ptr __attribute__((__weak__)); \ struct ath_hal_chip *AR9160_chip_ptr __attribute__((__weak__)); \ -struct ath_hal_chip **ah_chips_ptrs[] = { \ +struct ath_hal_chip *const *ah_chips_ptrs[] = { \ &AR5210_chip_ptr, \ &AR5211_chip_ptr, \ &AR5212_chip_ptr, \ &AR5312_chip_ptr, \ &AR5416_chip_ptr, \ - &AR9160_chip_ptr \ + &AR9160_chip_ptr, \ + NULL \ } #define DECLARE_ah_rfs \ @@ -83,14 +84,15 @@ struct ath_hal_rf *RF2425_rf_ptr __attribute__((__weak__)); \ struct ath_hal_rf *RF5111_rf_ptr __attribute__((__weak__)); \ struct ath_hal_rf *RF5112_rf_ptr __attribute__((__weak__)); \ struct ath_hal_rf *RF5413_rf_ptr __attribute__((__weak__)); \ -struct ath_hal_rf **ah_rfs_ptrs[] = { \ +struct ath_hal_rf *const *ah_rfs_ptrs[] = { \ &RF2316_rf_ptr, \ &RF2317_rf_ptr, \ &RF2413_rf_ptr, \ &RF2425_rf_ptr, \ &RF5111_rf_ptr, \ &RF5112_rf_ptr, \ - &RF5413_rf_ptr \ + &RF5413_rf_ptr, \ + NULL \ } #define OS_SET_DECLARE(set, ptype) \ @@ -100,10 +102,8 @@ struct ath_hal_rf **ah_rfs_ptrs[] = { \ typeof(sym) *__CONCAT(sym,_ptr) = &sym #define OS_SET_FOREACH(pvar, set) \ - int _i; \ - for (_i = 0, pvar = __CONCAT(set,_ptrs)[_i]; \ - _i < ARRAY_SIZE(__CONCAT(set,_ptrs)); \ - _i++, pvar = __CONCAT(set,_ptrs)[_i]) if (*pvar) + typeof(pvar) *ppvar = __CONCAT(set,_ptrs); \ + for (pvar = *ppvar; pvar; pvar = *++ppvar) if (*pvar) /* Byte order/swapping support. */ #define AH_LITTLE_ENDIAN 1234 -- 2.35.1