Skip to content

Commit

Permalink
Fix enum warnings in ath_hal's ar9300
Browse files Browse the repository at this point in the history
This fixes a number of clang 19 warnings:

    sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:709:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
      709 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
      148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
          |       ~~~ ^  ~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:745:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
      745 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
      148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
          |       ~~~ ^  ~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c:781:25: error: comparison of different enumeration types ('HAL_BOOL' and 'HAL_FREQ_BAND') [-Werror,-Wenum-compare]
      781 |         freq_array[i] = FBIN2FREQ(p_freq_bin[i], is_2ghz);
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h:148:11: note: expanded from macro 'FBIN2FREQ'
      148 |     (((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
          |       ~~~ ^  ~~~~~~~~~~~~~~~~~~

The `FBIN2FREQ()` and `FREQ2FBIN()` macros in `ar9300eep.h` are invoked
in most places around the `ath_hal` code with a (effectively) boolean
second argument, corresponding to "is this 2GHz?". But in the code that
is warned about, the value `HAL_FREQ_BAND_2GHZ` is of a different
non-boolean type, `HAL_FREQ_BAND`.

Update the `FBIN2FREQ()` and `FREQ2FBIN()` macros to interpret the
second argument as boolean value, and rename the macro parameter names
to better describe their meaning.

Reviewed by:	adrian, bz
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D46201
  • Loading branch information
DimitryAndric committed Aug 4, 2024
1 parent d471b4f commit 82246ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ enum Ar9300EepromTemplate
#define OSPREY_EEPMISC_WOW 0x02
#define OSPREY_CUSTOMER_DATA_SIZE 20

#define FREQ2FBIN(x,y) \
(u_int8_t)(((y) == HAL_FREQ_BAND_2GHZ) ? ((x) - 2300) : (((x) - 4800) / 5))
#define FBIN2FREQ(x,y) \
(((y) == HAL_FREQ_BAND_2GHZ) ? (2300 + x) : (4800 + 5 * x))
#define FREQ2FBIN(freq,is_2ghz) \
(u_int8_t)((is_2ghz) ? ((freq) - 2300) : (((freq) - 4800) / 5))
#define FBIN2FREQ(freq,is_2ghz) \
((is_2ghz) ? (2300 + freq) : (4800 + 5 * freq))
#define OSPREY_MAX_CHAINS 3
#define OSPREY_ANT_16S 25
#define OSPREY_FUTURE_MODAL_SZ 6
Expand Down

0 comments on commit 82246ac

Please sign in to comment.